From 7dac1f29fbaa76f9db86236b1ee810ff2acb32e5 Mon Sep 17 00:00:00 2001 From: Zachary Hancock Date: Wed, 6 Dec 2023 08:40:35 -0500 Subject: [PATCH] feat: add success log to disco sync (#584) --- .../core/management/commands/sync_with_discovery.py | 4 ++++ .../commands/test/test_sync_with_discovery.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/registrar/apps/core/management/commands/sync_with_discovery.py b/registrar/apps/core/management/commands/sync_with_discovery.py index aef23337..d399def0 100644 --- a/registrar/apps/core/management/commands/sync_with_discovery.py +++ b/registrar/apps/core/management/commands/sync_with_discovery.py @@ -37,6 +37,10 @@ def handle(self, *args, **options): self.sync_org_groups() self.sync_program_org_groups() + # load bearing log message. edx.org monitors for this log message + # to know when the sync has run successfully + logger.info('Sync with Discovery Service complete!') + def sync_organizations(self): """ Make API call to discovery service and get latest organizations list diff --git a/registrar/apps/core/management/commands/test/test_sync_with_discovery.py b/registrar/apps/core/management/commands/test/test_sync_with_discovery.py index 6ec34a55..7568b5ab 100644 --- a/registrar/apps/core/management/commands/test/test_sync_with_discovery.py +++ b/registrar/apps/core/management/commands/test/test_sync_with_discovery.py @@ -176,6 +176,18 @@ def test_sync_no_change(self): ] self.assert_organizations(orgs_to_sync, 9) + def test_success_output(self): + orgs_to_sync = [ + self.new_discovery_organization, + self.updating_discovery_organization, + self.discovery_other_org, + ] + self.mock_get_organizations_patcher.return_value = orgs_to_sync + self.mock_get_programs_by_types_patcher.return_value = [] + with patch('registrar.apps.core.management.commands.sync_with_discovery.logger') as mock_logger: + call_command(self.command) + mock_logger.info.assert_called_with('Sync with Discovery Service complete!') + @ddt.ddt class TestSyncProgramsWithDiscoveryCommand(TestSyncWithDiscoveryCommandBase):