def test_video_one_bidder_invalid_targeting_key(monkeypatch, cli_config): client = Client(CUSTOM_TARGETING, BIDDER_VIDEO_SVC_IDS, invalid_targeting_key=True) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() with pytest.raises(ResourceNotActive) as e_: gam.create_line_items() assert "'hb_pb_interactiveOff' is not active" in str(e_)
def test_video_priority_8(monkeypatch, cli_config): client = Client(CUSTOM_TARGETING, BIDDER_VIDEO_SVC_IDS) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() gam.create_line_items() assert len(gam.li_objs) == 1 assert {8} == {i_['priority'] for i_ in gam.li_objs[0].line_items} assert EXPECTED_LICA == gam.lica_objs
def test_banner_one_bidder(monkeypatch, cli_config): client = Client(CUSTOM_TARGETING, BIDDER_BANNER_SVC_IDS) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() gam.create_line_items() assert len(gam.li_objs) == 1 assert load_file('tests/resources/banner_expected.yml') == gam.li_objs[0].line_items assert BANNER_EXPECTED_LICA == gam.lica_objs
def test_video_one_bidder_custom_criteria(monkeypatch, cli_config): client = Client(CUSTOM_TARGETING, BIDDER_VIDEO_SVC_IDS) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() gam.create_line_items() assert len(gam.li_objs) == 1 assert load_file('tests/resources/video_expected_one_custom_value.yml') == gam.li_objs[0].line_items assert EXPECTED_LICA == gam.lica_objs
def test_missing_placement_resource(monkeypatch, cli_config): svc_ids = copy.deepcopy(BIDDER_VIDEO_SVC_IDS) svc_ids.update(dict(PlacementService={dump(dict(name="placement 2")): 3002})) client = Client(CUSTOM_TARGETING, svc_ids) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() with pytest.raises(ResourceNotFound) as e_: gam.create_line_items() assert "'placement 1' was not found" in str(e_)
def test_banner_safe_frame_vcpm(monkeypatch, cli_config): svc_ids = copy.deepcopy(BIDDER_BANNER_SVC_IDS) svc_ids.update(BIDDER_BANNER_SVC_IDS_NO_SIZE_OVERRIDE) client = Client(CUSTOM_TARGETING, svc_ids) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() gam.create_line_items() assert len(gam.li_objs) == 1 assert load_file('tests/resources/banner_vcpm_expected.yml') == gam.li_objs[0].line_items assert BANNER_EXPECTED_LICA_NO_SIZE_OVERRIDE == gam.lica_objs
def test_video_one_bidder_key_map(monkeypatch, cli_config): svc_ids = copy.deepcopy(BIDDER_VIDEO_SVC_IDS) svc_ids.update(BIDDER_VIDEO_BIDDER_KEY_MAP_SVC_IDS) client = Client(CUSTOM_TARGETING, svc_ids) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() gam.create_line_items() assert len(gam.li_objs) == 1 assert load_file('tests/resources/video_expected.yml') == gam.li_objs[0].line_items assert EXPECTED_LICA == gam.lica_objs
def test_dry_run(monkeypatch, cli_config): client = Client(CUSTOM_TARGETING, BIDDER_VIDEO_SVC_IDS) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() gam.create_line_items() gam.cleanup() assert len(gam.li_objs) == 1 assert load_file('tests/resources/video_expected_dry_run.yml') == \ gam.li_objs[0].line_items assert DRY_RUN_EXPECTED_LICA == gam.lica_objs
def test_archive_error(caplog, monkeypatch, cli_config): class ThisClient(Client): def performOrderAction(self, *args): return dict(numChanges=0) client = ThisClient(CUSTOM_TARGETING, BIDDER_VIDEO_SVC_IDS) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) caplog.set_level(ERROR) gam = GAMConfig() gam.create_line_items() gam.cleanup() assert 'Order archive, [6001], of 1 changes, reported 0 changes' in caplog.text
def test_video_single_order(monkeypatch, cli_config): svc_ids = copy.deepcopy(SINGLE_ORDER_SVC_IDS) svc_ids.update(SINGLE_ORDER_VIDEO_SVC_IDS) client = Client(CUSTOM_TARGETING, svc_ids) monkeypatch.setattr(ad_manager.AdManagerClient, "LoadFromString", lambda x: client) gam = GAMConfig() gam.create_line_items() assert gam.network['displayName'] == "Video Publisher" assert len(gam.li_objs) == 1 assert load_file('tests/resources/video_single_order_expected.yml') == \ gam.li_objs[0].line_items assert EXPECTED_LICA == gam.lica_objs gam.cleanup()