本文整理汇总了Python中tests.integration_tests.utilities.data_access_misc_queries.insert_test_company函数的典型用法代码示例。如果您正苦于以下问题:Python insert_test_company函数的具体用法?Python insert_test_company怎么用?Python insert_test_company使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insert_test_company函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_select_competitive_companies__non_published_companies
def test_select_competitive_companies__non_published_companies(self):
# create an industry
industry_id1 = ensure_id(insert_test_industry())
# create three companies. all published, besides company 3 that's new.
company_id1 = ensure_id(insert_test_company(workflow_status = "published"))
company_id2 = ensure_id(insert_test_company(workflow_status = "published"))
company_id3 = ensure_id(insert_test_company(workflow_status = "new"))
# add primary industries to all three companies.
self.main_access.mds.call_add_link("company", company_id1, 'primary_industry_classification', 'industry', industry_id1, "primary_industry", "industry_classification", self.context)
self.main_access.mds.call_add_link("company", company_id2, 'primary_industry_classification', 'industry', industry_id1, "primary_industry", "industry_classification", self.context)
self.main_access.mds.call_add_link("company", company_id3, 'primary_industry_classification', 'industry', industry_id1, "primary_industry", "industry_classification", self.context)
# query the competitions of company
competitive_companies = select_competitive_companies(company_id1)
# sort both the expected and real array so that the order doesn't matter
expected_competitive_companies = [
{ "_id": str(company_id1), "interval": None, "competition_strength": 1 },
{ "_id": str(company_id2), "interval": None, "competition_strength": 1 }
]
# make sure the competitions are correct
self.test_case.assertEqual(competitive_companies, expected_competitive_companies)
开发者ID:erezrubinstein,项目名称:aa,代码行数:26,代码来源:company_helper_test_collection.py
示例2: select_companies_by_name_for_typeahead
def select_companies_by_name_for_typeahead(self):
# create three companies. One complete match, one partial match, and one no match.
company_id_1 = ensure_id(insert_test_company(ticker = "w", name = "Woot", workflow_status = "published"))
company_id_2 = ensure_id(insert_test_company(ticker = "cw", name = "Chickenwoot", workflow_status = "published"))
company_id_3 = ensure_id(insert_test_company(ticker = "c", name = "chicken", workflow_status = "published"))
company_id_4 = ensure_id(insert_test_company(ticker = "cwoo", name = "chicken", workflow_status = "other"))
company_id_5 = ensure_id(insert_test_company(ticker = "woo", name = "WootWoot"))
# search for companies that match woo
matches = select_companies_by_name_for_typeahead("woo", hide_unpublished = True)
# make sure structure is correct
self.test_case.assertEquals(matches["header"], ["id", "name", "ticker", "score"])
self.test_case.assertEquals(matches["meta"], {
"num_rows": 2,
"page_index": 0,
"sort_direction": -1,
"page_size": 2,
"sort_index": 3
})
# make sure results are correct
matches = convert_entity_list_to_dictionary__array_format(matches["rows"])
self.test_case.assertEquals(matches, {
company_id_1: [company_id_1, "Woot", "w", 2],
company_id_2: [company_id_2, "Chickenwoot", "cw", 1]
})
开发者ID:erezrubinstein,项目名称:aa,代码行数:28,代码来源:company_helper_test_collection.py
示例3: test_select_company_ids_by_primary_industry_ids
def test_select_company_ids_by_primary_industry_ids(self):
# create three companies
company_id1 = insert_test_company()
company_id2 = insert_test_company()
company_id3 = insert_test_company()
# create three industries
industry_id1 = insert_test_industry()
industry_id2 = insert_test_industry()
industry_id3 = insert_test_industry()
# assign an industry per company
insert_new_industry_links(company_id1, [industry_id1], True, self.context)
insert_new_industry_links(company_id2, [industry_id2], True, self.context)
insert_new_industry_links(company_id3, [industry_id3], True, self.context)
# query the company ids for the first two industries
matching_companies = select_company_ids_by_primary_industry_ids([industry_id1, industry_id2])
# verify that it found both the first two companies and not the third
self.test_case.assertEqual(matching_companies, {
company_id1: industry_id1,
company_id2: industry_id2
})
开发者ID:erezrubinstein,项目名称:aa,代码行数:25,代码来源:company_helper_test_collection.py
示例4: main_export_get_stores_by_companies_and_dates__two_companies
def main_export_get_stores_by_companies_and_dates__two_companies(self):
# create three companies
company_id_1 = insert_test_company()
company_id_2 = insert_test_company()
company_id_3 = insert_test_company()
# create three rirs
rir_id_1 = insert_test_rir(self.context, company_id_1, '1')
rir_id_2 = insert_test_rir(self.context, company_id_2, '2')
rir_id_3 = insert_test_rir(self.context, company_id_3, '3')
# create three stores
store_helper = StoreHelper()
store_id_1 = ensure_id(store_helper.create_new_store(self.context, rir_id_1, async=False))
store_id_2 = ensure_id(store_helper.create_new_store(self.context, rir_id_2, async=False))
store_id_3 = ensure_id(store_helper.create_new_store(self.context, rir_id_3, async=False))
# update all stores to null intervals
# do batch update since normal update doesn't let us set to null........
query = {"_id": { "$in": [store_id_1, store_id_2, store_id_3]}}
self.mds_access.call_batch_update_entities("store", query, {"$set": { "interval": None }}, self.context)
# select the stores for two companies only
companies = [company_id_1, company_id_2]
dates = [datetime.datetime.utcnow()]
stores = ExportEndpoints(None, None)._get_stores_by_companies_and_dates(companies, dates, self.context)
# verify that only the first and second stores are there
stores = convert_entity_list_to_dictionary(stores)
self.test_case.assertEqual(len(stores), 2)
self.test_case.assertIn(store_id_1, stores)
self.test_case.assertIn(store_id_2, stores)
开发者ID:erezrubinstein,项目名称:aa,代码行数:32,代码来源:main_export_test_collection.py
示例5: test_select_competitive_companies
def test_select_competitive_companies(self):
# create two industries
industry_id1 = ensure_id(insert_test_industry())
industry_id2 = ensure_id(insert_test_industry())
# create three companies
company_id1 = ensure_id(insert_test_company(workflow_status = "published"))
company_id2 = ensure_id(insert_test_company(workflow_status = "published"))
company_id3 = ensure_id(insert_test_company(workflow_status = "published"))
# add primary industries to all three companies. Company 3 gets a different industry.
self.main_access.mds.call_add_link("company", company_id1, 'primary_industry_classification', 'industry', industry_id1, "primary_industry", "industry_classification", self.context)
self.main_access.mds.call_add_link("company", company_id2, 'primary_industry_classification', 'industry', industry_id1, "primary_industry", "industry_classification", self.context)
self.main_access.mds.call_add_link("company", company_id3, 'primary_industry_classification', 'industry', industry_id2, "primary_industry", "industry_classification", self.context)
# make industries 1 and 2 compete with each other
link_interval = [datetime.datetime(2012, 1, 1), datetime.datetime(2013, 2, 2)]
link_data = {"home_to_away": {"weight": .7}, "away_to_home": {"weight": .7}}
self.main_access.mds.call_add_link("industry", industry_id1, 'competitor', 'industry', industry_id2, "competitor", "industry_competition", self.context, link_interval = link_interval,
link_data = link_data)
# query the competitions of company
competitive_companies = select_competitive_companies(company_id1)
# sort both the expected and real array so that the order doesn't matter
expected_competitive_companies = sorted([
{ "_id": str(company_id1), "interval": None, "competition_strength": 1 },
{ "_id": str(company_id2), "interval": None, "competition_strength": 1 },
{ "_id": str(company_id3), "interval": [datetime.datetime(2012, 1, 1), datetime.datetime(2013, 2, 2)], "competition_strength": .7 }
])
competitive_companies = sorted(competitive_companies)
# make sure the competitions are correct
self.test_case.assertEqual(competitive_companies, expected_competitive_companies)
开发者ID:erezrubinstein,项目名称:aa,代码行数:35,代码来源:company_helper_test_collection.py
示例6: main_analytics_export_test_trade_area_monthly_demographics
def main_analytics_export_test_trade_area_monthly_demographics(self):
companies = [
insert_test_company(name="Company 0"),
insert_test_company(name="Company 1"),
insert_test_company(name="Company 2"),
insert_test_company(name="Company 3")
]
stores = [
insert_test_store(co_id, [datetime.datetime(2010, 1, 1), None])
for co_id in companies
]
num_trade_areas = 100
for _ in range(num_trade_areas):
insert_test_trade_area(stores[0], companies[0],
analytics=self.__get_sample_analytics_dict(companies, stores))
params = {
"sortIndex": 0,
"sortDirection": 1,
"fieldFilters": None,
"pageIndex": 0,
"pageSize": 20
}
preset_url = "export/preset/analytics/%s/trade_area/monthly_total_population" % companies[0]
self.main_access.call_get_preset(preset_url, params, self.context)
开发者ID:erezrubinstein,项目名称:aa,代码行数:31,代码来源:main_analytics_export_test_collection.py
示例7: retail_test_create_white_space_competition_set
def retail_test_create_white_space_competition_set(self):
good_company_analytics = {
"stores": {
"monthly": {
"store_counts": [
{
"date": LAST_ANALYTICS_DATE.strftime("%Y-%m-%dT%H:%M:%S"),
"value": 1
}
]
}
}
}
bad_company_analytics1 = copy.deepcopy(good_company_analytics)
bad_company_analytics1["stores"]["monthly"]["store_counts"][0]["date"] = \
get_datetime_months_ago(1, start=LAST_ANALYTICS_DATE).strftime("%Y-%m-%dT%H:%M:%S")
bad_company_analytics2 = copy.deepcopy(good_company_analytics)
bad_company_analytics2["stores"]["monthly"]["store_counts"][0]["value"] = 0
cid1 = insert_test_company(name="C1", ctype="retail_banner", analytics=good_company_analytics)
cid2 = insert_test_company(name="C2", ctype="retail_banner", analytics=good_company_analytics)
cid3 = insert_test_company(name="C3", ctype="retail_banner", analytics=good_company_analytics)
banner_id = cid1
competition_set = [
{"id": cid2, "name": "C2", "weight": 0.8, "enabled": True},
{"id": cid3, "name": "C3", "weight": 1, "enabled": False}
]
wscomp1 = self.wscomp_controller.create_white_space_competition_set(self.user_test, banner_id, competition_set)
self.test_case.assertDictEqual(wscomp1, {
"id": wscomp1["id"],
"user": wscomp1["user"],
"banner_id": banner_id,
"competition_set": competition_set,
"modified_date": wscomp1["modified_date"],
"creation_date": wscomp1["creation_date"]
})
creation_date1 = parse_date(wscomp1["creation_date"])
self.test_case.assertTrue(creation_date1 <= datetime.datetime.utcnow())
wscomp2 = self.wscomp_controller.create_white_space_competition_set(self.user_test, banner_id, competition_set)
# get the test user again to account for session activity date & count changes
self.user_test = self.user_controller.User.get("[email protected]")
# Same ID as before (updated, not re-created), same creation date, and same user
self.test_case.assertDictEqual(wscomp2, {
"id": wscomp1["id"],
"user": self.user_test.serialize(),
"banner_id": banner_id,
"competition_set": competition_set,
"modified_date": wscomp2["modified_date"],
"creation_date": wscomp1["creation_date"]
})
开发者ID:erezrubinstein,项目名称:aa,代码行数:59,代码来源:retail_web_white_space_competition_set_test_collection.py
示例8: main_test_get_entity_type_summary
def main_test_get_entity_type_summary(self):
company_id1 = insert_test_company()
company_id2 = insert_test_company()
company_id3 = insert_test_company()
company_id4 = insert_test_company()
main_summary = self.main_access.call_get_entity_type_summary("company")
mds_summary = self.mds_access.call_get_entity_type_summary("company")
self.test_case.assertEqual(main_summary, mds_summary)
开发者ID:erezrubinstein,项目名称:aa,代码行数:10,代码来源:main_test_collection.py
示例9: __insert_ccis
def __insert_ccis(self):
ind_data = {
"source_vendor": "TEST",
"source_version": 2013,
"industry_code": "1111",
"industry_name": "HELO"
}
self.inds = [
insert_test_industry(name="Industry %s" % i, data=dict(ind_data, industry_name="Industry %s" % i))
for i in range(4)
]
parents = [
insert_test_company(ticker="P%s" % i, name="Parent %s" % i, type="retail_parent", status="operating")
for i in range(4)
]
# Create companies
self.cids = [
ensure_id(insert_test_company(ticker="TICK%s" % i, name="Company %s" % i, type="retail_banner", status="operating"))
for i in range(4)
]
for i in range(4):
self.mds_access.call_add_link("company", parents[i], "retail_parent", "company", self.cids[i],
"retail_segment", "retailer_branding", self.context)
self.mds_access.call_add_link("industry", self.inds[i], "primary_industry", "company", self.cids[i],
"primary_industry_classification", "industry_classification", self.context)
entity_pairs = [{
'pair_interval_from_to': [None, None],
'pair_interval_to_from': [None, None],
'to_id': self.cids[0],
'pair_data_to_from': {"competition_strength": 1.0},
'pair_data_from_to': {"competition_strength": 1.0},
'from_id': self.cids[0]
}]
for i, cid in enumerate(self.cids[1:]):
entity_pairs.append({
'pair_interval_from_to': [None, None],
'pair_interval_to_from': [None, None],
'to_id': cid,
'pair_data_to_from': {"competition_strength": round(0.5 - i * 0.2, 1)},
'pair_data_from_to': {"competition_strength": round(0.5 + i * 0.2, 1)},
'from_id': self.cids[0]
})
return self.mds_access.call_create_pair_entities(entity_pairs, "company", "competitor", "company",
"competitor", "company_competition", self.context)
开发者ID:erezrubinstein,项目名称:aa,代码行数:51,代码来源:pair_entity_test_collection.py
示例10: main_test_get_data_entities
def main_test_get_data_entities(self):
company_ids = [insert_test_company(), insert_test_company(), insert_test_company(), insert_test_company()]
fields = ["_id", "entity_type", "name", "data.ticker"]
params = self.main_params.create_params(resource = "get_data_entities", fields = fields)
companies = self.main_access.call_get_data_entities("company", params = params["params"])["rows"]
self.test_case.assertEqual(len(companies), 4)
for company in companies:
self.test_case.assertIn(company["_id"], company_ids)
self.test_case.assertEqual(company["name"], "UNITTESTCOMPANY")
self.test_case.assertEqual(company["entity_type"], "company")
self.test_case.assertEqual(company["data.ticker"], "")
开发者ID:erezrubinstein,项目名称:aa,代码行数:14,代码来源:main_test_collection.py
示例11: test_orphan_cci_fixer
def test_orphan_cci_fixer(self):
# make test companies
company_id1 = insert_test_company(name="ABC")
company_id2 = insert_test_company(name="Easy as 123")
company_id3 = insert_test_company(name="Do re mi")
company_id4 = insert_test_company(name="You and me")
# pair 'em up
_ = insert_test_company_competition_instance(company_id1, company_id2)
_ = insert_test_company_competition_instance(company_id3, company_id4)
# make sure we have CCIs for the pairs
query = {
"$or":[
{"data.pair.entity_id_from": ensure_id(company_id1), "data.pair.entity_id_to": ensure_id(company_id2)},
{"data.pair.entity_id_from": ensure_id(company_id2), "data.pair.entity_id_to": ensure_id(company_id1)},
{"data.pair.entity_id_from": ensure_id(company_id3), "data.pair.entity_id_to": ensure_id(company_id4)},
{"data.pair.entity_id_from": ensure_id(company_id4), "data.pair.entity_id_to": ensure_id(company_id3)}
]
}
fields = ["_id", "name", "data"]
params = self.main_params.mds.create_params(resource="find_entities_raw", query=query, entity_fields=fields)["params"]
ccis = self.main_access.mds.call_find_entities_raw("company_competition_instance", params, self.context)
# should be 4 CCIs
self.test_case.assertEqual(len(ccis), 4)
# delete one of the companies
self.main_access.mds.call_del_entity("company", company_id1)
# run orphan cci fixer
self.__run_and_test_orphan_cci_fixer()
# make sure we have 2 CCIs left; the other two should be deleted
query = {
"$or":[
{"data.pair.entity_id_from": ensure_id(company_id1), "data.pair.entity_id_to": ensure_id(company_id2)},
{"data.pair.entity_id_from": ensure_id(company_id2), "data.pair.entity_id_to": ensure_id(company_id1)},
{"data.pair.entity_id_from": ensure_id(company_id3), "data.pair.entity_id_to": ensure_id(company_id4)},
{"data.pair.entity_id_from": ensure_id(company_id4), "data.pair.entity_id_to": ensure_id(company_id3)}
]
}
fields = ["_id", "name", "data"]
params = self.main_params.mds.create_params(resource="find_entities_raw", query=query, entity_fields=fields)["params"]
ccis = self.main_access.mds.call_find_entities_raw("company_competition_instance", params, self.context)
# should be 2 CCIs
self.test_case.assertEqual(len(ccis), 2)
开发者ID:erezrubinstein,项目名称:aa,代码行数:49,代码来源:wfs_cleanup_tasks_test_collection.py
示例12: test_select_competitive_companies__multiple_competition_records
def test_select_competitive_companies__multiple_competition_records(self):
"""
This verifies a specific case where a company has multiple industries.
"""
# create three industries
industry_id1 = ensure_id(insert_test_industry())
industry_id2 = ensure_id(insert_test_industry())
industry_id3 = ensure_id(insert_test_industry())
# create three companies
company_id1 = ensure_id(insert_test_company(workflow_status = "published"))
company_id2 = ensure_id(insert_test_company(workflow_status = "published"))
company_id3 = ensure_id(insert_test_company(workflow_status = "published"))
# add industry1 as the primary for company1. industry two as the primary for company 2 and as the secondary for company 3.
self.main_access.mds.call_add_link("company", company_id1, 'primary_industry_classification', 'industry', industry_id1, "primary_industry", "industry_classification", self.context)
self.main_access.mds.call_add_link("company", company_id2, 'primary_industry_classification', 'industry', industry_id2, "primary_industry", "industry_classification", self.context)
self.main_access.mds.call_add_link("company", company_id3, 'secondary_industry_classification', 'industry', industry_id2, "secondary_industry", "industry_classification", self.context)
# also add industry 3 as a secondary of company 2
self.main_access.mds.call_add_link("company", company_id2, 'secondary_industry_classification', 'industry', industry_id3, "secondary_industry", "industry_classification", self.context)
# make industries 1 and 2 compete with each other
link_interval = [datetime.datetime(2012, 1, 1), datetime.datetime(2013, 2, 2)]
link_data = {"home_to_away": {"weight": .7}, "away_to_home": {"weight": .7}}
self.main_access.mds.call_add_link("industry", industry_id1, 'competitor', 'industry', industry_id2, "competitor", "industry_competition", self.context, link_interval = link_interval,
link_data = link_data)
# make industries 1 and 3 compete with each other
# this will make sure that the numbers for company 2 will use dates and weight from the primary industry, not secondary
link_interval = [datetime.datetime(2012, 5, 5), datetime.datetime(2013, 6, 6)]
link_data = { "competition_strength": .9 }
link_data = {"home_to_away":{"weight": .9}, "away_to_home": {"weight": .9}}
self.main_access.mds.call_add_link("industry", industry_id1, 'competitor', 'industry', industry_id3, "competitor", "industry_competition", self.context, link_interval = link_interval,
link_data = link_data)
# query the competitions of company
competitive_companies = select_competitive_companies(company_id1)
# create expected company array and make sure only one interval is returned and it matches the competition record I'm looking for
expected_competitive_companies = [
{ "_id": str(company_id1), "interval": None, "competition_strength": 1 },
{ "_id": str(company_id2), "interval": [datetime.datetime(2012, 1, 1), datetime.datetime(2013, 2, 2)], "competition_strength": .7 }
]
competitive_companies = sorted(competitive_companies)
# make sure the competitions are correct
self.test_case.assertEqual(competitive_companies, expected_competitive_companies)
开发者ID:erezrubinstein,项目名称:aa,代码行数:49,代码来源:company_helper_test_collection.py
示例13: test_mds_count
def test_mds_count(self):
# insert three companies
company_id_1 = insert_test_company()
company_id_2 = insert_test_company()
company_id_3 = insert_test_company()
# get count of all companies and verify
count_all = self.main_access.mds.call_count_entities("company")
self.test_case.assertEqual(count_all, 3)
# get count of first two ids and verify
query = { "_id": { "$in": [company_id_1, company_id_2] }}
count = self.main_access.mds.call_count_entities("company", query)
self.test_case.assertEqual(count, 2)
开发者ID:erezrubinstein,项目名称:aa,代码行数:15,代码来源:mds_test_collection.py
示例14: test_most_correct_rir_fixer
def test_most_correct_rir_fixer(self):
cid = insert_test_company(type="retail_banner")
sid1 = insert_test_store(cid, [None, None])
sid2 = insert_test_store(cid, [None, None])
sid3 = insert_test_store(cid, [None, None])
sid4 = insert_test_store(cid, [None, None])
sid5 = insert_test_store(cid, [None, None])
rid1 = insert_test_rir(self.context, cid, is_most_correct=True)
rid2 = insert_test_rir(self.context, cid)
rid3 = insert_test_rir(self.context, cid)
rid4 = insert_test_rir(self.context, cid, is_most_correct=True)
rid5 = insert_test_rir(self.context, cid)
self._link_rir_to_store(rid1, sid1, is_most_correct=True)
self._link_rir_to_store(rid2, sid2, is_most_correct=True)
self._link_rir_to_store(rid3, sid3, is_most_correct=True)
self._link_rir_to_store(rid4, sid4)
self._link_rir_to_store(rid5, sid5)
# rub, baby, run!
task_rec = {
"input": { "scheduled": False },
"meta": { "async": False }
}
self.main_access.wfs.call_task_new("retail_curation", "cleanup", "most_correct_rir_fixer", task_rec, self.context)
# verify each rir is now correct... oy vey.
self._verify_rir(rid1, True)
self._verify_rir(rid2, True)
self._verify_rir(rid3, True)
self._verify_rir(rid4, False)
self._verify_rir(rid5, False)
开发者ID:erezrubinstein,项目名称:aa,代码行数:35,代码来源:wfs_cleanup_tasks_test_collection.py
示例15: retail_test_company_typeahead
def retail_test_company_typeahead(self):
cids1 = [
insert_test_company(name="COMPANY %s" % i, workflow_status="published")
for i in range(80)
]
cids2 = [
insert_test_company(name="COMPANY %s" % i)
for i in range(81, 100)
]
response = self.web_access.get('/api/company_typeahead?query=c', cookies=self.cooks).json()
self.test_case.assertEqual(response["companies"]["meta"]["num_rows"], 80)
self.test_case.assertEqual(response["companies"]["meta"]["page_size"], 10)
开发者ID:erezrubinstein,项目名称:aa,代码行数:16,代码来源:retail_web_company_typeahead_test_collection.py
示例16: main_test_get_entity_summary
def main_test_get_entity_summary(self):
company_id = insert_test_company()
main_summary = self.main_access.call_get_entity_summary("company", company_id)
mds_summary = self.mds_access.call_get_entity_summary("company", company_id)
self.test_case.assertEqual(main_summary, mds_summary)
开发者ID:erezrubinstein,项目名称:aa,代码行数:7,代码来源:main_test_collection.py
示例17: web_test_unlock_task
def web_test_unlock_task(self):
self.test_case.maxDiff = None
i = 0
status = "locked"
ind_name = "IND%s" % i
iid = insert_test_industry(name=ind_name)
co_name = "CO%s" % i
cid = insert_test_company(name=co_name)
rid = insert_test_rir(self.context, cid, company_name=co_name)
email = "email%s" % i
t = self.__form_task_rec(iid, cid, rid, status, email)
params = {
"query": t,
"update": {"$set": t},
"upsert": True
}
self.wfs_access.call_find_and_modify_task(params, self.context)
task_id = self.web_access.get("/api/retail_input/matching_workflow/%s" % status, "",
headers=self.json_headers, cookies=self.cooks).json()["results"][0][1]
task = self.web_access.put("/api/retail_input/task/%s/unlock" % task_id, json.dumps({}),
headers=self.json_headers, cookies=self.cooks).json()
self.test_case.assertDictEqual(task, {
"task": {
"_id": task_id,
"task_status": {
"status": "open"
}
}
})
开发者ID:erezrubinstein,项目名称:aa,代码行数:35,代码来源:core_web_workflow_validation_test_collection.py
示例18: main_export_test_retail_input_records
def main_export_test_retail_input_records(self):
company_id = insert_test_company()
rir_id_A = insert_test_rir(self.context, company_id, '1')
rir_id_B = insert_test_rir(self.context, company_id, '2')
resource = "/export/preset/retail_input_records"
rirs = self.main_access.call_get_preset(resource, None, self.context)
rir_export_meta = {"has_header": True,
"has_metadata": True,
"num_rows": 2,
"row_format": "list"}
# self.test_case.assertEqual(rirs["meta"], rir_export_meta)
self.test_case.assertEqual(rirs["meta"]["num_rows"], rir_export_meta["num_rows"])
self.test_case.assertEqual(rirs["id_field"], None)
self.test_case.assertEqual(rirs["id_index"], None)
self.test_case.assertEqual(rirs["field_list"], RETAIL_INPUT_RECORD_EXPORT_CLEAN_FIELDS)
self.test_case.assertEqual(rirs["field_meta"], RETAIL_INPUT_RECORD_EXPORT_FIELD_META)
self.test_case.assertEqual(len(rirs["results"]), 2)
for rir in rirs["results"]:
self.test_case.assertEqual(len(rir), len(RETAIL_INPUT_RECORD_EXPORT_DB_FIELDS))
self.test_case.assertTrue(rir[0] in [rir_id_A, rir_id_B])
开发者ID:erezrubinstein,项目名称:aa,代码行数:25,代码来源:main_export_test_collection.py
示例19: main_export_stores
def main_export_stores(self):
store_helper = StoreHelper()
company_id = insert_test_company()
rir_id_A = insert_test_rir(self.context, company_id, '1')
store_id_A = store_helper.create_new_store(self.context, rir_id_A, async=False)
rir_id_B = insert_test_rir(self.context, company_id, '2')
store_id_B = store_helper.create_new_store(self.context, rir_id_B, async=False)
resource = "/export/preset/stores"
stores = self.main_access.call_get_preset(resource, None, self.context)
store_export_meta = {'num_rows': 2,
'page_index': 0,
'page_size': 2,
'sort_direction': 1,
'sort_index': 0}
self.test_case.assertEqual(stores["meta"], store_export_meta)
self.test_case.assertEqual(stores["id_field"], None)
self.test_case.assertEqual(stores["id_index"], None)
self.test_case.assertEqual(stores["field_list"], STORE_EXPORT_CLEAN_FIELDS)
self.test_case.assertEqual(stores["field_meta"], STORE_EXPORT_FIELD_META)
self.test_case.assertEqual(len(stores["results"]), 2)
for store in stores["results"]:
self.test_case.assertEqual(len(store), len(STORE_EXPORT_FINAL_DB_FIELDS))
self.test_case.assertTrue(store[0] in [store_id_A, store_id_B])
开发者ID:erezrubinstein,项目名称:aa,代码行数:29,代码来源:main_export_test_collection.py
示例20: entity_matcher_test_entity_vs_entity_inexact_match
def entity_matcher_test_entity_vs_entity_inexact_match(self):
test_company_id = insert_test_company()
address = '260 Park Ave.'
zipcode = '11101'
city = 'Manhattan'
c = 'Microsoft'
comparable_id = insert_test_rir(self.context, test_company_id, '1', None, c, address, city, 'NY', zipcode)
# Create a few records which are different in small ways
addr_id = insert_test_rir(self.context, test_company_id, '1', None, c, "270 Park Ave. S.", city, 'NY', zipcode)
city_id = insert_test_rir(self.context, test_company_id, '1', None, c, address, 'New York', 'NY', zipcode)
zip_id = insert_test_rir(self.context, test_company_id, '1', None, c, address, city, 'NY', '11100')
long_id = insert_test_rir(self.context, test_company_id, '1', None, c, address, city, 'NY', zipcode, longitude=-80.11)
lat_id = insert_test_rir(self.context, test_company_id, '1', None, c, address, city, 'NY', zipcode, latitude=40.01)
mult_id = insert_test_rir(self.context, test_company_id, '1', None, c, address + " S.", 'New York', 'NY', '11100')
different_ids = [addr_id, city_id, zip_id, long_id, lat_id, mult_id]
# Assert for all the inexact records
for rir_id in different_ids:
result = self.entity_matcher_access.call_match_entity_vs_entity('retail_input_record', comparable_id, rir_id)
test_rir_results = result["details"][comparable_id]
self.test_case.assertEqual("inexact", test_rir_results[rir_id]["category"])
self.test_case.assertEqual("match", test_rir_results[rir_id]["matcher_prediction"])
self.test_case.assertGreater(test_rir_results[rir_id]["score"], 0.59)
开发者ID:erezrubinstein,项目名称:aa,代码行数:27,代码来源:entity_matcher_test_collection.py
注:本文中的tests.integration_tests.utilities.data_access_misc_queries.insert_test_company函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论