From a6e8141c1b5b722c53c26c67f3d301ebc9c3f5e0 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 27 Dec 2023 12:16:09 -0700 Subject: [PATCH] Add mock to master script --- .../test_transition_domain_migrations.py | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/registrar/tests/test_transition_domain_migrations.py b/src/registrar/tests/test_transition_domain_migrations.py index 1fe513999..fab669d53 100644 --- a/src/registrar/tests/test_transition_domain_migrations.py +++ b/src/registrar/tests/test_transition_domain_migrations.py @@ -707,17 +707,19 @@ class TestMigrations(TestCase): def run_master_script(self): # noqa here (E501) because splitting this up makes it # confusing to read. - with patch( - "registrar.management.commands.utility.terminal_helper.TerminalHelper.query_yes_no_exit", # noqa - return_value=True, - ): - call_command( - "master_domain_migrations", - runMigrations=True, - migrationDirectory=self.test_data_file_location, - migrationJSON=self.migration_json_filename, - disablePrompts=True, - ) + mock_client = MockSESClient() + with boto3_mocking.clients.handler_for("sesv2", mock_client): + with patch( + "registrar.management.commands.utility.terminal_helper.TerminalHelper.query_yes_no_exit", # noqa + return_value=True, + ): + call_command( + "master_domain_migrations", + runMigrations=True, + migrationDirectory=self.test_data_file_location, + migrationJSON=self.migration_json_filename, + disablePrompts=True, + ) def compare_tables( self, @@ -1030,7 +1032,8 @@ class TestMigrations(TestCase): # this is one of the email addresses in data/test_contacts.txt output_stream = StringIO() - with boto3_mocking.clients.handler_for("sesv2", MockSESClient): + mock_client = MockSESClient() + with boto3_mocking.clients.handler_for("sesv2", mock_client): # also have to re-point the logging handlers to output_stream with less_console_noise(output_stream): call_command("send_domain_invitations", "testuser@gmail.com", stdout=output_stream) @@ -1051,7 +1054,8 @@ class TestMigrations(TestCase): # these are two email addresses in data/test_contacts.txt output_stream = StringIO() - with boto3_mocking.clients.handler_for("sesv2", MockSESClient): + mock_client = MockSESClient() + with boto3_mocking.clients.handler_for("sesv2", mock_client): # also have to re-point the logging handlers to output_stream with less_console_noise(output_stream): call_command(