def test_create_board_item_look_item_call(mocker): test_board_item = models.HomepageItem(title="taco", description="burrito", look_id="42") mocker.patch("looker_deployer.commands.deploy_boards.match_look_id") mocker.patch.object(sdk, "create_homepage_item") deploy_boards.match_look_id.return_value = "1" deploy_boards.create_board_item(test_board_item, 10, sdk, sdk) sdk.create_homepage_item.assert_called_with( models.HomepageItem(title="taco", description="burrito", look_id="1", url="/looks/1", homepage_section_id=10))
def create_board_item(source_board_item_object, target_board_section_id, source_sdk, target_sdk): dashboard_id = None look_id = None url = None if source_board_item_object.dashboard_id: dashboard_id = match_dashboard_id(source_board_item_object.dashboard_id, source_sdk, target_sdk) url = f"/dashboards/{str(dashboard_id)}" if source_board_item_object.look_id: look_id = match_look_id(source_board_item_object.look_id, source_sdk, target_sdk) url = f"/looks/{str(look_id)}" new_board_item = models.HomepageItem( title=source_board_item_object.title, description=source_board_item_object.description, dashboard_id=dashboard_id, look_id=look_id, url=url, homepage_section_id=target_board_section_id ) logger.info( "Creating item", extra={ "section_id": new_board_item.homepage_section_id, "dashboard_id": new_board_item.dashboard_id, "look_id": new_board_item.look_id, "url": new_board_item.url } ) resp = target_sdk.create_homepage_item(new_board_item) logger.info("Item created", extra={"id": resp.id}) return resp
def test_create_board_item_look_match_call(mocker): test_board_item = models.HomepageItem(title="taco", description="burrito", look_id="42") mocker.patch("looker_deployer.commands.deploy_boards.match_look_id") mocker.patch.object(sdk, "create_homepage_item") deploy_boards.create_board_item(test_board_item, 1, sdk, sdk) deploy_boards.match_look_id.assert_called_with("42", sdk, sdk)
def test_create_board_item_look(mocker): test_board_item = models.HomepageItem(title="taco", description="burrito", look_id="42") test_board_item_resp = MockHomepageItem() mocker.patch("looker_deployer.commands.deploy_boards.match_look_id") mocker.patch.object(sdk, "create_homepage_item") deploy_boards.match_look_id.return_value = "1" sdk.create_homepage_item.return_value = test_board_item_resp board_item = deploy_boards.create_board_item(test_board_item, 1, sdk, sdk) assert board_item == test_board_item_resp