"""Test vendor_accounts module of Apple Music Streams ETL.""" import pytest from feed_ingestion.flows.apple_music_streams import vendor_accounts @pytest.fixture() def mock_vendors_accounts(monkeypatch): """Mock vendors accounts.""" licensors = { 'theorchard': {'2016-01-01': {'default': ['80028967', '80029727']}}, 'sme': { '2016-01-01': {'default': ['1', '2']}, '2017-01-01': { 'default': ['3', '4'], 'amStreams': ['3']}, '2018-01-01': {'default': ['5', '6', '7']}, '2019-01-01': {'default': ['8', '9', '10']}} } monkeypatch.setattr(vendor_accounts, 'licensors', licensors) def test_get_vendors_theorchard(mock_vendors_accounts): """Test get_vendors with theorchard licensor.""" result = vendor_accounts.get_vendors('2020-06-01', 'theorchard') assert result == ['80028967', '80029727'] def test_get_vendors_with_sme_current_date(mock_vendors_accounts): """Test get_vendors with sme licensor and current date.""" result = vendor_accounts.get_vendors('2020-06-01', 'sme') assert result == ['8', '9', '10'] def test_get_vendors_with_sme_middle_date(mock_vendors_accounts): """Test get_vendors with sme licensor and date in the middle of period.""" result = vendor_accounts.get_vendors('2018-06-01', 'sme') assert result == ['5', '6', '7'] def test_get_vendors_with_sme_exact_date(mock_vendors_accounts): """Test get_vendors with sme licensor and start date of period.""" result = vendor_accounts.get_vendors('2017-01-01', 'sme') assert result == ['3', '4'] def test_get_vendors_with_report(mock_vendors_accounts): """Test get_vendors with sme licensor and particular report name.""" result = vendor_accounts.get_vendors('2017-01-02', 'sme', 'amStreams') assert result == ['3'] def test_get_vendors_with_non_defined_report(mock_vendors_accounts): """Test get_vendors with theorchard licensor and current date.""" result = vendor_accounts.get_vendors('2019-01-01', 'sme', 'amStreams') assert result == ['8', '9', '10']