"""Unit tests for Meta Daily config module.""" import pytest from feed_ingestion.flows.meta_daily import config class TestConfigReports: """Validate the report definitions in config.""" @pytest.mark.parametrize('report', ['consumption', 'production']) def test_report_has_required_keys(self, report): assert 'staging_raw_table' in config.reports[report] assert 'events_column' in config.reports[report] assert 'sources' in config.reports[report] @pytest.mark.parametrize( 'report,expected_table', [ ('consumption', 'staging_raw_meta_consumption'), ('production', 'staging_raw_meta_production'), ], ) def test_staging_raw_table_names(self, report, expected_table): assert config.reports[report]['staging_raw_table'] == expected_table @pytest.mark.parametrize( 'report,expected_column', [ ('consumption', 'VIEWS'), ('production', 'CREATIONS'), ], ) def test_events_column_names(self, report, expected_column): assert config.reports[report]['events_column'] == expected_column @pytest.mark.parametrize('report', ['consumption', 'production']) def test_each_report_has_both_licensors(self, report): licensors = [s['licensor'] for s in config.reports[report]['sources']] assert config.LICENSOR_SME in licensors assert config.LICENSOR_ORCHARD in licensors @pytest.mark.parametrize('report', ['consumption', 'production']) def test_sources_have_required_keys(self, report): for source in config.reports[report]['sources']: assert 'licensor' in source assert 'drop_path' in source assert 'file_name' in source @pytest.mark.parametrize('report', ['consumption', 'production']) def test_drop_path_contains_date_placeholder(self, report): for source in config.reports[report]['sources']: assert '{date}' in source['drop_path'] @pytest.mark.parametrize('report', ['consumption', 'production']) def test_file_name_contains_date_placeholder(self, report): for source in config.reports[report]['sources']: assert '{date}' in source['file_name'] class TestConfigS3: """Validate the S3 configuration.""" def test_s3_drop_has_bucket(self): assert 'bucket' in config.s3['drop'] def test_s3_archive_has_bucket_and_path(self): assert 'bucket' in config.s3['archive'] assert 'path' in config.s3['archive'] def test_archive_path_contains_date_placeholder(self): assert '{date}' in config.s3['archive']['path'] class TestConfigConstants: """Validate module-level constants.""" def test_feed_name(self): assert config.feed_name == 'meta_daily' def test_licensor_constants(self): assert config.LICENSOR_SME == 'sme' assert config.LICENSOR_ORCHARD == 'theorchard'