本文整理汇总了Python中geoprocessing.business_logic.business_objects.store.Store.change_type方法的典型用法代码示例。如果您正苦于以下问题:Python Store.change_type方法的具体用法?Python Store.change_type怎么用?Python Store.change_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geoprocessing.business_logic.business_objects.store.Store
的用法示例。
在下文中一共展示了Store.change_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_stores_to_change_log
# 需要导入模块: from geoprocessing.business_logic.business_objects.store import Store [as 别名]
# 或者: from geoprocessing.business_logic.business_objects.store.Store import change_type [as 别名]
def test_save_stores_to_change_log(self):
try:
# insert a new file into the db
source_file_id = self._data_repository.insert_source_file("UNITTEST_FILE_PATH", "2012-01-01", 1000)
# create 5 fake stores
company_id = insert_test_company()
address_id = insert_test_address(-40, 40)
store_id1 = insert_test_store(company_id, address_id)
store_id2 = insert_test_store(company_id, address_id)
store_id3 = insert_test_store(company_id, address_id)
store_id4 = insert_test_store(company_id, address_id)
store_id5 = insert_test_store(company_id, address_id)
# create list of 2 deleted stores
deleted_store_ids = [store_id1, store_id2]
# create list of 3 changed stores
store3 = Store()
store3.store_id = store_id3
store3.change_type = StoreChangeType.StoreConfirmed
store3.mismatched_parameters = []
store4 = Store()
store4.store_id = store_id4
store4.change_type = StoreChangeType.StoreUpdated
store4.mismatched_parameters = ['chicken', 'beef']
store5 = Store()
store5.store_id = store_id5
store5.change_type = StoreChangeType.StoreOpened
store5.mismatched_parameters = []
changed_stores = [store3, store4, store5]
# add the change_longs for the 5 stores (2 deleted, one opened, one confirmed, one updated)
source_file_id = self._data_repository.save_stores_to_change_log(deleted_store_ids, changed_stores, "2012-01-01", source_file_id)
# select the change log entries and verify their contents
change_logs = select_stores_change_log_entries(source_file_id)
# verify deleted stores
# store 1
self.assertEqual(len(change_logs), 5)
self.assertEqual(change_logs[0].store_id, store_id1)
self.assertEqual(change_logs[0].log_date, datetime(2012, 1, 1))
self.assertEqual(change_logs[0].change_type_id, StoreChangeType.StoreClosed)
self.assertIsNone(change_logs[0].comment)
self.assertEqual(change_logs[0].source_file_id, source_file_id)
# store 2
self.assertEqual(change_logs[1].store_id, store_id2)
self.assertEqual(change_logs[1].log_date, datetime(2012, 1, 1))
self.assertEqual(change_logs[1].change_type_id, StoreChangeType.StoreClosed)
self.assertIsNone(change_logs[1].comment)
self.assertEqual(change_logs[1].source_file_id, source_file_id)
# store 3
self.assertEqual(change_logs[2].store_id, store_id3)
self.assertEqual(change_logs[2].log_date, datetime(2012, 1, 1))
self.assertEqual(change_logs[2].change_type_id, StoreChangeType.StoreConfirmed)
self.assertEqual(change_logs[2].comment, '[]')
self.assertEqual(change_logs[2].source_file_id, source_file_id)
# store 4
self.assertEqual(change_logs[3].store_id, store_id4)
self.assertEqual(change_logs[3].log_date, datetime(2012, 1, 1))
self.assertEqual(change_logs[3].change_type_id, StoreChangeType.StoreUpdated)
self.assertEqual(change_logs[3].comment, "['chicken', 'beef']")
self.assertEqual(change_logs[3].source_file_id, source_file_id)
# store 5
self.assertEqual(change_logs[4].store_id, store_id5)
self.assertEqual(change_logs[4].log_date, datetime(2012, 1, 1))
self.assertEqual(change_logs[4].change_type_id, StoreChangeType.StoreOpened)
self.assertEqual(change_logs[4].comment, "[]")
self.assertEqual(change_logs[4].source_file_id, source_file_id)
except:
raise
finally:
delete_store_change_logs_by_source_file_id(source_file_id)
delete_test_source_file(source_file_id)
delete_test_store(store_id1)
delete_test_store(store_id2)
delete_test_store(store_id3)
delete_test_store(store_id4)
delete_test_store(store_id5)
delete_test_address(address_id)
delete_test_company(company_id)