From ce3d9d035c300615a5c9b07c402aa15b7aff360d Mon Sep 17 00:00:00 2001 From: bobby-didcoding <bobby@didcoding.com> Date: Mon, 18 Mar 2024 14:30:43 +0000 Subject: [PATCH] fixed broken IMF ingest tests --- .../commands/import_market_guides_data.py | 1 + .../commands/tests/test_import_data.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dataservices/management/commands/import_market_guides_data.py b/dataservices/management/commands/import_market_guides_data.py index c596d00f..2f42d471 100644 --- a/dataservices/management/commands/import_market_guides_data.py +++ b/dataservices/management/commands/import_market_guides_data.py @@ -56,6 +56,7 @@ def handle(self, *args, **options): self.stderr.write(self.style.ERROR(e)) send_ingest_error_notify_email(table_view_names['view_name'], e) else: + print("test") self.stdout.write(self.style.NOTICE(f'{table_view_names["view_name"]} does not need updating')) self.stdout.write(self.style.SUCCESS('Finished Market Guides import!')) diff --git a/dataservices/management/commands/tests/test_import_data.py b/dataservices/management/commands/tests/test_import_data.py index 9485f98c..ef122429 100644 --- a/dataservices/management/commands/tests/test_import_data.py +++ b/dataservices/management/commands/tests/test_import_data.py @@ -388,8 +388,15 @@ def test_import_world_economic_outlook_data(read_sql_mock, world_economic_outloo assert len(models.WorldEconomicOutlookByCountry.objects.all()) == 0 management.call_command('import_countries') + + # Dry run management.call_command('import_world_economic_outlook_data') + assert len(models.WorldEconomicOutlookByCountry.objects.all()) == 0 + + # Write option + management.call_command('import_world_economic_outlook_data', '--write') + assert len(models.WorldEconomicOutlookByCountry.objects.all()) == 10 @@ -426,7 +433,7 @@ def test_import_metadata_source_data_filter_tables(): @pytest.mark.django_db @pytest.mark.parametrize( 'env, review_requested_x_times', - [('dev', 0), ('staging', 3), ('uat', 0), ('production', 0)], + [('dev', 0), ('staging', 4), ('uat', 0), ('production', 0)], ) @mock.patch('dataservices.management.commands.import_market_guides_data.call_command') @mock.patch('dataservices.management.commands.helpers.MarketGuidesDataIngestionCommand.should_ingestion_run') @@ -439,6 +446,7 @@ def test_import_market_guides_data( 'import_uk_total_trade_data', 'import_uk_trade_in_goods_data', 'import_uk_trade_in_services_data', + 'import_world_economic_outlook_data', ] mock_should_run.return_value = False management.call_command('import_market_guides_data', '--write') @@ -446,7 +454,7 @@ def test_import_market_guides_data( mock_should_run.return_value = True management.call_command('import_market_guides_data', '--write') - assert mock_call_command.call_count == 6 + assert mock_call_command.call_count == 8 assert mock_send_review_request.call_count == review_requested_x_times for command in command_list: @@ -462,12 +470,13 @@ def test_import_market_guides_data_dry_run(mock_call_command, mock_should_run): 'import_uk_total_trade_data', 'import_uk_trade_in_goods_data', 'import_uk_trade_in_services_data', + 'import_world_economic_outlook_data', ] mock_should_run.return_value = True management.call_command('import_market_guides_data') - assert mock_call_command.call_count == 6 + assert mock_call_command.call_count == 8 for command in command_list: assert command in str(mock_call_command.call_args_list) @@ -486,9 +495,9 @@ def test_import_market_guides_data_error(mock_call_command, mock_should_run, moc management.call_command('import_market_guides_data') mock_email_string = str(mock_error_email.mock_calls) - assert mock_call_command.call_count == 3 + assert mock_call_command.call_count == 4 assert 'oops' in str(mock_call_command.side_effect) - assert mock_error_email.call_count == 3 + assert mock_error_email.call_count == 4 assert 'area_of_error' in mock_email_string assert 'error_type' in mock_email_string assert 'error_details' in mock_email_string