"""Unit tests for Snapchat class overriding StageLoader.""" from unittest.mock import call from unittest.mock import MagicMock from feed_ingestion.flows.snapchat.stage_loader import SnapchatSL def test_load_staging_raw_table(monkeypatch): """Test load_staging_raw_table method.""" executor = MagicMock() sql_loader = MagicMock() execute_mock = MagicMock() stage_name = 'test_stage' stage_raw_table = 'staging_raw_test_table' date = '2020-01-01' source_files_dict = { 'files': [ { 'file_name': 'Orchard_PYS6_D_creations', 'file_size': 1000 } ] } monkeypatch.setattr( SnapchatSL, 'resolve_sql_loader_and_execute', execute_mock) stage_loader = SnapchatSL(executor, sql_loader) stage_loader.load_staging_raw_table( stage_raw_table, source_files_dict, date, stage_name, report='creations') class FileNameCondition: def __init__(self, file_name): self.file_name = file_name def __eq__(self, other): return other.get('file_name', 'oops') == self.file_name calls = [ call( None, params=FileNameCondition(file_dict['file_name']) ) for file_dict in source_files_dict['files'] ] execute_mock.assert_has_calls(calls)