當前位置: 首頁>>代碼示例>>Python>>正文


Python Store._opened_date方法代碼示例

本文整理匯總了Python中geoprocessing.business_logic.business_objects.store.Store._opened_date方法的典型用法代碼示例。如果您正苦於以下問題:Python Store._opened_date方法的具體用法?Python Store._opened_date怎麽用?Python Store._opened_date使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在geoprocessing.business_logic.business_objects.store.Store的用法示例。


在下文中一共展示了Store._opened_date方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_matched_open_store_from_db

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
def get_matched_open_store_from_db(address_id, company_id, phone, store_format):

    statement = '''
        select
            s.store_id,
            s.company_id,
            s.address_id,
            s.phone_number,
            s.store_format,
            s.company_generated_store_number,
            s.note,
            s.opened_date,
            s.assumed_opened_date
        from stores s
        where s.address_id = %d and s.company_id = %d and s.phone_number %s and s.store_format %s
            and s.closed_date is null and s.assumed_closed_date is null''' % (address_id, company_id, select_clean_up_string(phone), select_clean_up_string(store_format))

    db_store_params = sql_execute(statement)

    if len(db_store_params) > 0:
        db_store = Store()
        db_store.store_id = db_store_params[0].store_id
        db_store.company_id = db_store_params[0].company_id
        db_store.address_id = db_store_params[0].address_id
        db_store.phone_number = db_store_params[0].phone_number
        db_store._opened_date = db_store_params[0].opened_date
        db_store._assumed_opened_date = db_store_params[0].assumed_opened_date
        db_store.store_format = db_store_params[0].store_format
        db_store.company_generated_store_number = db_store_params[0].company_generated_store_number
        db_store.note = db_store_params[0].note
        return db_store
    else:
        return None
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:35,代碼來源:store_handler.py

示例2: test_synchronize_competitive_stores__upserts_properly

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
    def test_synchronize_competitive_stores__upserts_properly(self):
        """
        This test verifies that calling synchronize_competitive_stores_in_db will insert/update any competitive_stores are new or existing
        """
        # create a mock home store
        home_store = Store()
        home_store.store_id = 1
        home_store.company_id = 1
        home_store._opened_date = "2012-01-01"
        home_store._assumed_opened_date = "2012-01-01"

        # create three mock stores
        existing_competitor = StoreCompetitionInstance.basic_init(2, 2, -1, -1)
        new_competitor = StoreCompetitionInstance.basic_init(4, 4, -1, -1)

        # add the mock stores as existing competitive stores (by id)
        # !!!! VERY IMPORTANT TO DO A DEEP COPY.  This makes it work like a database (i.e. different objects) when doing set comparisons
        self._data_repository.competitive_stores[1] = [copy.deepcopy(existing_competitor)]

        # create existing set of competitive stores, which consists of only one of the mock stores and a new competitor
        away_stores = [existing_competitor, new_competitor]
        competitive_stores = CompetitiveStoreHelper(home_store, away_stores, 10, self._data_repository)

        # call synchronize and verify that the right store was closed
        competitive_stores.synchronize_competitive_stores_in_db()
        self.assertEqual(self._data_repository.batch_upserted_competitive_stores, [
            competitive_stores._create_batch_competition_structure(existing_competitor, datetime(2012, 01, 01), None, True, home_store.store_id),
            competitive_stores._create_batch_competition_structure(new_competitor, datetime(2012, 01, 01), None, True, home_store.store_id)
        ])
        self.assertEqual(self._data_repository.batch_upserted_trade_area_id, 10)
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:32,代碼來源:test_competitive_store_helper.py

示例3: get_matched_open_store_from_db_by_core_store_id

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
def get_matched_open_store_from_db_by_core_store_id(core_store_id):

    statement = '''
        select
            s.store_id,
            s.company_id,
            s.address_id,
            s.phone_number,
            s.store_format,
            s.company_generated_store_number,
            s.note,
            s.opened_date,
            s.assumed_opened_date
        from stores s
        where core_store_id = '%s' and s.closed_date is null and s.assumed_closed_date is null''' % core_store_id

    db_store_params = sql_execute(statement)
    if len(db_store_params) > 0:
        db_store = Store()
        db_store.store_id = db_store_params[0].store_id
        db_store.company_id = db_store_params[0].company_id
        db_store.address_id = db_store_params[0].address_id
        db_store.phone_number = db_store_params[0].phone_number
        db_store._opened_date = db_store_params[0].opened_date
        db_store._assumed_opened_date = db_store_params[0].assumed_opened_date
        db_store.store_format = db_store_params[0].store_format
        db_store.company_generated_store_number = db_store_params[0].company_generated_store_number
        db_store.note = db_store_params[0].note
        return db_store
    else:
        return None
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:33,代碼來源:store_handler.py

示例4: test_synchronize_competitive_stores__competitive_company_instance_opens_after_competitive_stores

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
    def test_synchronize_competitive_stores__competitive_company_instance_opens_after_competitive_stores(self):
        """
        This verifies that it is inserted if stores' open/closed dates are still open but competitive_companies start after
        """
        # create a mock home store
        home_store = Store()
        home_store.store_id = 1
        home_store.company_id = 1
        home_store._assumed_opened_date = "1900-01-01"
        home_store._opened_date = "1900-01-01"
        home_store._assumed_closed_date = None
        home_store._closed_date = None

        # create three mock stores
        new_competitor = StoreCompetitionInstance.standard_init(4, 4, -1, -1, None, None, "1900-01-01", None, "1900-01-01", None, "2011-01-01", None)

        # create existing set of competitive stores, which consists of only one of the mock stores and a new competitor
        away_stores = [new_competitor]
        competitive_stores = CompetitiveStoreHelper(home_store, away_stores, 10, self._data_repository)

        # call synchronize and verify that the right store was inserted with the right dates
        competitive_stores.synchronize_competitive_stores_in_db()
        self.assertEqual(self._data_repository.batch_upserted_competitive_stores, [
            competitive_stores._create_batch_competition_structure(new_competitor, datetime(2011, 1, 1), None, True, home_store.store_id)
        ])
        self.assertEqual(self._data_repository.batch_upserted_trade_area_id, 10)
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:28,代碼來源:test_competitive_store_helper.py

示例5: Store

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
    def test_synchronize_competitive_stores__competitive_company_instance_opens_after_competitive_stores_close(self):
        """
        This verifies that NOTHING is inserted if stores' close before companies become competitive
        """
        # create a mock home store
        home_store = Store()
        home_store.store_id = 1
        home_store.company_id = 1
        home_store._assumed_opened_date = "2009-01-01"
        home_store._opened_date = "2009-01-01"
        home_store._assumed_closed_date = "2010-12-01"
        home_store._closed_date = "2010-12-01"

        # create three mock stores
        new_competitor = StoreCompetitionInstance.standard_init(4, 4, -1, -1, None, None, "2009-01-01", "2010-12-01", "2009-01-01", "2010-12-01", "2011-01-01", "2011-12-01")

        # create existing set of competitive stores, which consists of only one of the mock stores and a new competitor
        away_stores = [new_competitor]
        competitive_stores = CompetitiveStoreHelper(home_store, away_stores, 10, self._data_repository)

        # call synchronize and verify that the right store was inserted with the right dates
        competitive_stores.synchronize_competitive_stores_in_db()
        self.assertEqual(len(self._data_repository.upserted_away_stores), 0)
        self.assertEqual(self._data_repository.batch_upserted_competitive_stores, [])
        self.assertEqual(self._data_repository.batch_upserted_trade_area_id, 10)
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:27,代碼來源:test_competitive_store_helper.py

示例6: test_synchronize_competitive_stores__stores_overlap_in_dates__home_store_dates_within_away_store

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
    def test_synchronize_competitive_stores__stores_overlap_in_dates__home_store_dates_within_away_store(self):
        """
        This verifies that it is inserted if stores' open/closed dates do overlap with home store contained between the away store dates
        """
        # create a mock home store
        home_store = Store()
        home_store.store_id = 1
        home_store.company_id = 1
        home_store._assumed_opened_date = "2011-01-01"
        home_store._opened_date = "2011-01-01"
        home_store._assumed_closed_date = "2011-12-01"
        home_store._closed_date = "2011-12-01"

        # create three mock stores
        new_competitor = StoreCompetitionInstance.standard_init(4, 4, -1, -1, None, None, "2010-01-01", "2012-12-01", "2010-01-01", "2012-12-01", None, None)

        # create existing set of competitive stores, which consists of only one of the mock stores and a new competitor
        away_stores = [new_competitor]
        competitive_stores = CompetitiveStoreHelper(home_store, away_stores, 10, self._data_repository)

        # call synchronize and verify that the right store was inserted with the right dates
        competitive_stores.synchronize_competitive_stores_in_db()
        self.assertEqual(self._data_repository.batch_upserted_competitive_stores, [
            competitive_stores._create_batch_competition_structure(new_competitor, datetime(2011, 01, 01), datetime(2011, 12, 01), True, home_store.store_id)
        ])
        self.assertEqual(self._data_repository.batch_upserted_trade_area_id, 10)
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:28,代碼來源:test_competitive_store_helper.py

示例7: get_open_store_ids_and_open_dates_for_company

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
def get_open_store_ids_and_open_dates_for_company(company_info):
    statement = '''
                    SELECT
                        store_id,
                        opened_date,
                        assumed_opened_date
                    FROM stores
                    WHERE company_id = ? AND closed_date is null AND assumed_closed_date is null AND assumed_opened_date < ?'''
    row = sql_execute_with_parameters([company_info.company_id, company_info.as_of_date], statement)
    stores = []
    for store_triple in row:
        store = Store()
        store.store_id = store_triple.store_id
        store._opened_date = store_triple.opened_date
        store._assumed_opened_date = store_triple.assumed_opened_date
        stores.append(store)
    return stores
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:19,代碼來源:store_handler.py

示例8: test_synchronize_competitive_stores__upsert__away_store_closes_before_home_store_opens

# 需要導入模塊: from geoprocessing.business_logic.business_objects.store import Store [as 別名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import _opened_date [as 別名]
    def test_synchronize_competitive_stores__upsert__away_store_closes_before_home_store_opens(self):
        """
        This verifies that nothing is inserted if stores' open/closed dates do not overlap
        """
        # create a mock home store
        home_store = Store()
        home_store.store_id = 1
        home_store.company_id = 1
        home_store._assumed_opened_date = "2012-01-01"
        home_store._opened_date = "2012-01-01"

        # create three mock stores
        new_competitor = StoreCompetitionInstance.standard_init(4, 4, -1, -1, None, None, "1900-01-01", "2011-01-01", "1900-01-01", "2011-01-01", None, None)

        # create existing set of competitive stores, which consists of only one of the mock stores and a new competitor
        away_stores = [new_competitor]
        competitive_stores = CompetitiveStoreHelper(home_store, away_stores, 10, self._data_repository)

        # call synchronize and verify that nothing was inserted
        competitive_stores.synchronize_competitive_stores_in_db()
        self.assertEqual(len(self._data_repository.upserted_away_stores), 0)
        self.assertEqual(self._data_repository.batch_upserted_competitive_stores, [])
        self.assertEqual(self._data_repository.batch_upserted_trade_area_id, 10)
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:25,代碼來源:test_competitive_store_helper.py


注:本文中的geoprocessing.business_logic.business_objects.store.Store._opened_date方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。