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


Python Dependency.call_get_preset方法代碼示例

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


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

示例1: test_retail_get_whitespace_stores

# 需要導入模塊: from common.utilities.inversion_of_control import Dependency [as 別名]
# 或者: from common.utilities.inversion_of_control.Dependency import call_get_preset [as 別名]
    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])
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:29,代碼來源:retail_white_space_test_collection.py

示例2: test_retail_get_whitespace_grid

# 需要導入模塊: from common.utilities.inversion_of_control import Dependency [as 別名]
# 或者: from common.utilities.inversion_of_control.Dependency import call_get_preset [as 別名]
    def test_retail_get_whitespace_grid(self):

        main_access = Dependency("CoreAPIProvider").value

        grid_name = "Grid 100 mile x 100 mile"
        threshold = "GridDistanceMiles100"
        grid_id = insert_test_white_space_grid(threshold, grid_name)

        another_grid_name = "Random Grid 7 mile x 7 mile"
        another_threshold = "GridDistanceMiles7"
        another_grid_id = insert_test_white_space_grid(threshold, another_grid_name)

        grid_cell_1_poly = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]
        grid_cell_2_poly = [[[1, 0], [1, 1], [2, 1], [2, 0], [1, 0]]]
        grid_cell_3_poly = [[[0, 1], [0, 2], [1, 2], [1, 1], [0, 1]]]
        grid_cell_4_poly = [[[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]]

        grid_cell_1_id = insert_test_white_space_grid_cell(grid_id, grid_cell_1_poly, threshold, grid_name, 0.5, 0.5)
        grid_cell_2_id = insert_test_white_space_grid_cell(grid_id, grid_cell_2_poly, threshold, grid_name, 1.5, 0.5)
        grid_cell_3_id = insert_test_white_space_grid_cell(grid_id, grid_cell_3_poly, threshold, grid_name, 0.5, 1.5)
        grid_cell_4_id = insert_test_white_space_grid_cell(another_grid_id, grid_cell_4_poly, another_threshold,
                                                           another_grid_name, 1.5, 1.5)

        context = {}
        params = {}

        resource = "/data/preset/whitespace/grid/%s" % threshold
        data = main_access.call_get_preset(resource, params=params, context=context)
        grid_cells = data["grid_cells"]

        grid_cells_dict = {}
        for grid_cell in grid_cells:
            grid_cells_dict[grid_cell[0]] = grid_cell[1]

        self.test_case.assertEqual(len(grid_cells), 3)
        self.test_case.assertItemsEqual(grid_cells_dict[grid_cell_1_id], grid_cell_1_poly)
        self.test_case.assertItemsEqual(grid_cells_dict[grid_cell_2_id], grid_cell_2_poly)
        self.test_case.assertItemsEqual(grid_cells_dict[grid_cell_3_id], grid_cell_3_poly)

        is_grid_cell_4_returned = grid_cell_4_id in grid_cells_dict.keys()
        self.test_case.assertEqual(is_grid_cell_4_returned, False)
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:43,代碼來源:retail_white_space_test_collection.py


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