"""Unit tests for tasks of Spotify Marketshare Week Ending Workflow.""" from datetime import datetime from unittest.mock import MagicMock import pytest from feed_ingestion.flows.spotify_marketshare_week_ending import config from feed_ingestion.flows.spotify_marketshare_week_ending import tasks _date = '2022-05-04' _date_obj = datetime.strptime('2022-05-04', '%Y-%m-%d') def mock_remove_files_from_path(activity, path, return_deleted_files=False): """Return a deleted file.""" files = { 's3.files_removed': ['filename.xlsx', ], } return files @pytest.fixture def expected_bootstrap_response(): """Response for bootstrap task.""" return { 'feed_name': config.feed_name, 'secrets_path': config.secrets_path, 'date': _date, 's3_archive_path': config.s3['archive'].format(date=_date_obj), 's3_download_path': config.s3['drop_path'], 'report': config.file_pattern.format(date=_date_obj), 'temp_staging_raw_table': config.snowflake_table_names[ 'temp_staging_raw'].format(date=_date_obj), 'staging_raw_table': config.snowflake_table_names['staging_raw'], 'source_files_dict': { 'files': [ {'file_name': config.file_pattern.format(date=_date_obj)} ]} } def test_bootstrap( expected_bootstrap_response): """Test bootstrap task.""" result = tasks.bootstrap( activity=MagicMock(), date=_date, reload=None) assert result == expected_bootstrap_response