"""Unit tests for tasks of Store Specific Youtube Adjustment Workflow.""" from unittest.mock import MagicMock import pytest from feed_ingestion.flows.youtube_adjustment import config from feed_ingestion.flows.youtube_adjustment import tasks @pytest.fixture def context(): """Context for Store Specific Youtube Adjustment tasks.""" return {'activity': MagicMock()} @pytest.fixture def expected_bootstrap_response(context): """Response for bootstrap task.""" return { 'cms_dict': [ { 'asset_root': 'asset_conflict_report_theorchardmusic_N_v1-0.csv', 'adjustment_root': 'YouTube_263000_theorchardmusic_label_AP*_report.csv', 'CMS': 'ORCH'}, { 'asset_root': '', 'adjustment_root': 'YouTube_9_dmgi_label_AP_*_report.csv', 'CMS': 'ENT'}], 'adjustment_dir': ( 's3://dev-cucumbers/filedrop/videoservices/' 'rights_mgmt/adjustment_report/'), 's3_root': 's3://dev-cucumbers/etl/videoservices/rights_mgmt/', 'ya_format': 'dev.test.YT_ADJUSTMENT', 'dev_table': 'LY_DEV.TEST.ADJUSTMENT', 'prod_table': 'dev.YOUTUBE_ANALYTICS.ADJUSTMENT_V2', 'report_table': 'dev.YOUTUBE_ANALYTICS.ADJUSTMENT_REPORT', 'asset_view_table': 'dev.YOUTUBE_MAPPING.ASSET_VIEW', 'email_list': [ 'datarequests@theorchard.com', 'conflicts@theorchard.com']} def test_bootstrap(monkeypatch, context, expected_bootstrap_response): """Test bootstrap task.""" monkeypatch.setattr( config, 'STORE_SPECIFIC_YOUTUBE_ADJUSTMENT_FORMAT', 'dev.test.YT_ADJUSTMENT') monkeypatch.setattr( config, 'ADJUSTMENT_DEV_TABLE', 'LY_DEV.TEST.ADJUSTMENT') monkeypatch.setattr( config, 'ADJUSTMENT_PROD_TABLE', 'dev.YOUTUBE_ANALYTICS.ADJUSTMENT_V2') monkeypatch.setattr( config, 'ADJUSTMENT_REPORT_TABLE', 'dev.YOUTUBE_ANALYTICS.ADJUSTMENT_REPORT') monkeypatch.setattr( config, 'ASSET_VIEW_TABLE', 'dev.YOUTUBE_MAPPING.ASSET_VIEW') result = tasks.bootstrap(**context) assert result == expected_bootstrap_response