"""Test snowflake_change_history model.""" from datetime import date from unittest.mock import patch from ows_product_physical.connector import snowflake from ows_product_physical.models import snowflake_change_history as model def test_get_products_for_new_delivery_with_store_id(): """Test get_physical_product_change_history.""" items = {'product_ids': [2136606, 3706158], 'store_id': 1705} expected_db = [ [ ( 2136606, 'deletions', None, None, None, None, None, None, 'N', 'Y' ), ( 2136606, 'sale_start_date', date(2022, 4, 29), date(2022, 5, 27), None, None, None, None, None, None ), ], ] expected_result = [ { 'field_name': 'deletions', 'new_deletion_status': 'Y', 'new_embargo_date': None, 'new_price': None, 'new_sale_start_date': None, 'old_deletion_status': 'N', 'old_embargo_date': None, 'old_price': None, 'old_sale_start_date': None }, { 'field_name': 'sale_start_date', 'new_deletion_status': None, 'new_embargo_date': None, 'new_price': None, 'new_sale_start_date': '2022-05-27', 'old_deletion_status': None, 'old_embargo_date': None, 'old_price': None, 'old_sale_start_date': '2022-04-29' } ] with patch.object(snowflake, 'fetchall', side_effect=expected_db): actual_result = model.get_physical_product_change_history(**items) assert actual_result assert actual_result.message == { '2136606-1705': expected_result, '3706158-1705': [], }