"""Unit tests for tasks of Youtube Weekly Workflow.""" from unittest.mock import MagicMock import pytest from feed_ingestion.flows.youtube_weekly import config from feed_ingestion.flows.youtube_weekly import tasks _date = '2018-02-12' @pytest.fixture def expected_bootstrap_response(): """Response for bootstrap task.""" s3_archive_path = 's3://{bucket}/{dir}'.format( bucket=config.data_bucket, dir='Youtube_weekly/archives_v1_1/2018-02-12/') s3_download_path = 's3://{bucket}/{dir}'.format( bucket=config.data_bucket, dir='ftp/youtube/') source_files_dict = {'files': [ { 'file_name': ( 'YouTube_theorchardmusic_W_20180212_' 'claim_raw_v1-1.csv.gz') }]} return { 'feed_name': config.feed_name, 'secrets_path': config.secrets_path, 'date': _date, 's3_archive_path': s3_archive_path, 's3_download_path': s3_download_path, 'source_files_dict': source_files_dict, 'staging_raw_table': config.staging_raw_table_name} def test_bootstrap(expected_bootstrap_response): """Bootstrap should return expected response.""" result = tasks.bootstrap(MagicMock(), date=_date) assert result == expected_bootstrap_response