本文整理汇总了Python中common.utilities.inversion_of_control.Dependency类的典型用法代码示例。如果您正苦于以下问题:Python Dependency类的具体用法?Python Dependency怎么用?Python Dependency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dependency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_retail_get_whitespace_stores
def test_retail_get_whitespace_stores(self):
main_access = Dependency("CoreAPIProvider").value
company_id = insert_test_company()
trade_area_1 = insert_test_geoprocessed_trade_area(home_store_id=1, away_store_id=21, company_id=company_id,
company_name="woot", opened_date=None, closed_date=None,
longitude=35, latitude=-40)
trade_area_2 = insert_test_geoprocessed_trade_area(home_store_id=2, away_store_id=22, company_id=company_id,
company_name="woot", opened_date=None, closed_date=None,
longitude=36, latitude=-41)
trade_area_3 = insert_test_geoprocessed_trade_area(home_store_id=3, away_store_id=23, company_id=999,
company_name="woot", opened_date=None, closed_date=None,
longitude=37, latitude=-42)
params = {
"bannerIds": [company_id]
}
context = {}
resource = "/data/preset/whitespace/stores"
data = main_access.call_get_preset(resource, params=params, context=context)
stores = data["stores"]
self.test_case.assertEqual(len(stores), 2)
self.test_case.assertItemsEqual(stores[0][-6], [35, -40])
self.test_case.assertItemsEqual(stores[1][-6], [36, -41])
示例2: __init__
def __init__(self, server_ip_address):
self._rest_provider = Dependency("RestProvider", HasMethods("download_file")).value
self._config = Dependency("Config", HasAttributes("ArcGIS_timeout", "ArcGIS_max_errors")).value
self._logger = Dependency("LogManager", HasMethods("error")).value
self._server_ip_address = server_ip_address
self._timeout = self._config.ArcGIS_timeout
self._max_error_count = self._config.ArcGIS_max_errors
示例3: test_baonline_auth_context
def test_baonline_auth_context():
# get logging dependency
logger = Dependency("LogManager").value
# this is how it would look in geoprocessing (without the debugs of course
with BAOnlineAuthContext() as bao:
logger.info("get, token: %s, num_auth_requests: %s", bao.token, bao.num_auth_requests)
response = get_report_templates(bao)
logger.info("templates: %s", pprint.pformat(response))
示例4: select_count_trade_area_by_store
def select_count_trade_area_by_store(store_id):
# get dependencies
core_api_provider = Dependency("CoreAPIProvider").value
param_builder = Dependency("CoreAPIParamsBuilder").value
# create params
filters = { "link.relation_type": "store_trade_area" }
params = param_builder.create_get_data_entities_params(field_filters = filters)["params"]
# run query and return first id
return len(core_api_provider.call_get_data_entities_linked_from("trade_area", "store", store_id, params)["rows"])
示例5: __init__
def __init__(self, target_db_name, company_settings):
# init yo'self
self.target_db_name = target_db_name
self.company_settings = company_settings
# get some dependencies
self.mds_access = Dependency("CoreAPIProvider").value.mds
self.mds_params = Dependency("CoreAPIParamsBuilder").value.mds
# get some helpers
self._fast_date_parser = FastDateParser()
示例6: __init__
def __init__(self):
# get dependencies
self.logger = Dependency("LogManager").value
self.config = Dependency("Config", HasAttributes("ba_online_username", "ba_online_password")).value
self.rest_provider = Dependency("RestProvider").value
# get username and password
self.user_name = self.config.ba_online_username
self.password = self.config.ba_online_password
# various internal vars
self.num_auth_requests = 0
示例7: setUp
def setUp(self):
# call setUp on super class
super(TestRetailMDSMonitor, self).setUp()
# register mox dependencies
register_common_mox_dependencies(self.mox)
# get mock dependencies that we need to use for recording
self.mock_rest_provider = Dependency("RestProvider").value
self.mock_email_provider = Dependency("EmailProvider").value
# helper vars
self.stats_url = "http://localhost:5001/connection_stats"
示例8: setUp
def setUp(self):
# call parent set up
super(TestCustomAnalyticsExecutor, self).setUp()
# register mock dependencies
register_common_mox_dependencies(self.mox)
# get some mock dependencies
self.mock_deployment_provider = Dependency("DeploymentProvider").value
self.mock_cloud_provider = Dependency("CloudProviderNewEnvironment").value
self.mock_logger = Dependency("LogManager").value
self.mock_email_provider = Dependency("EmailProvider").value
self.mock_config = Dependency("Config").value
示例9: __init__
def __init__(self):
self.__data_repository = Dependency("DataRepository").value
self.store_id = None
self.company_id = None
self.address_id = None
self.phone_number = None
self.note = None
self.store_format = None
self.company_generated_store_number = None
# id from core
self.core_store_id = None
# these are derived parameters that are generated for the loader. they are not "pure" store properties
self.change_type = None
self.mismatched_parameters = []
# these are protected members. they should be accessed by their properties below
self._opened_date = None
self._closed_date = None
self._assumed_opened_date = None
self._assumed_closed_date = None
# for lazy loading
self.__problem_longitude = None
self.__problem_latitude = None
self.__address = None
示例10: setUp
def setUp(self):
# call parent set up
super(GP16Tests, self).setUp()
# register mock dependencies
register_mox_gp_dependencies(self.mox)
# Set mock attributes on WorkflowService instance for calls to ignore
self.mock_main_access = Dependency("CoreAPIProvider").value
self.mock_mds_access = Dependency("MDSMongoAccess").value
# create the mock trade _area
self.trade_area_id = 11
self.store_id = "woot!"
self.trade_area = {
"_id" : self.trade_area_id,
"data" : {
"store_id": self.store_id,
"company_id": "buddy!",
"latitude" : 1,
"longitude" : -1,
"store_opened_date": "2012-01-01",
"store_closed_date": "2013-12-31"
}
}
# create the test gp
self.gp = GP16GetStoreWeather()
self.gp._entity = self.trade_area
示例11: delete_competitive_stores
def delete_competitive_stores(trade_area_id):
# get dependency
core_api_provider = Dependency("CoreAPIProvider").value
param_builder = Dependency("CoreAPIParamsBuilder").value
# create params
filters = { "link.relation_type": "store_trade_area_competition" }
params = param_builder.create_get_data_entities_params(field_filters = filters)["params"]
# get links and store_ids
links = core_api_provider.call_get_data_entities_linked_from("store", "trade_area", trade_area_id, params)["rows"]
# for each store, delete link
for link in links:
# bomboj for
core_api_provider.mds.call_del_link_without_id("store", link["to._id"], "away_store", "trade_area", trade_area_id, "trade_area", "store_trade_area_competition")
示例12: setUp
def setUp(self):
# call super init
super(MDSParamsBuilderTests, self).setUp()
# register mox dependencies
register_common_mox_dependencies(self.mox)
# get mocked params builder
self.mds_params_builder = Dependency("CoreAPIParamsBuilder").value.mds
示例13: __init__
def __init__(self):
self.trade_area_id = None
self.store_id = None
self.threshold_id = None
self.period_id = None
self.area = None
self.__wkt_representation = None
self.__data_repository = Dependency("DataRepository", HasMethods("insert_trade_area_shape")).value
示例14: initialize
def initialize(self):
self.user_id = '[email protected]'
self.source = "main_test_collection.py"
self.context = {"user_id": self.user_id, "source": self.source}
self.remote_dirs = ['integration_test_files/', 'integration_test_files/chuck_norris/']
self.local_dir = 'implementation/data/'
self.main_params = Dependency("CoreAPIParamsBuilder").value
self.store_helper = StoreHelper()
示例15: delete_test_competitors
def delete_test_competitors(company_id):
# get dependency
core_api_provider = Dependency("CoreAPIProvider").value
param_builder = Dependency("CoreAPIParamsBuilder").value
# create params
filters = {
"link.relation_type": "company_competition"
}
params = param_builder.create_get_data_entities_params(field_filters = filters)["params"]
# get links
links = core_api_provider.call_get_data_entities_linked_from("company", "company", company_id, params)["rows"]
# delete links
for link in links:
# bomboj for
core_api_provider.mds.call_del_link_without_id("company", company_id, "competitor", "company", link["to._id"], "competitor", "company_competition")