Skip to content

Commit aa26c22

Browse files
committed
refactor Command Handle handle method
cleaner name for method
1 parent f35752d commit aa26c22

File tree

9 files changed

+11
-11
lines changed

9 files changed

+11
-11
lines changed

manage_breast_screening/notifications/management/commands/create_appointments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def add_arguments(self, parser):
3737
)
3838

3939
def handle(self, *args, **options):
40-
with CommandHandler.command_handler(INSIGHTS_JOB_NAME):
40+
with CommandHandler.handle(INSIGHTS_JOB_NAME):
4141
logger.info("Create Appointments command started")
4242
container_client = BlobStorage().find_or_create_container(
4343
os.getenv("BLOB_CONTAINER_NAME", "")

manage_breast_screening/notifications/management/commands/create_reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def add_arguments(self, parser):
5858
parser.add_argument("--smoke-test", action="store_true")
5959

6060
def handle(self, *args, **options):
61-
with CommandHandler.command_handler(INSIGHTS_JOB_NAME):
61+
with CommandHandler.handle(INSIGHTS_JOB_NAME):
6262
logger.info("Create Report Command started")
6363

6464
bso_codes, report_configs = self.configuration(options)

manage_breast_screening/notifications/management/commands/helpers/command_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class CommandHandler:
1111
@contextmanager
1212
@staticmethod
13-
def command_handler(command_name):
13+
def handle(command_name):
1414
try:
1515
yield
1616
ApplicationInsightsLogging().custom_event_info(

manage_breast_screening/notifications/management/commands/retry_failed_message_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Command(BaseCommand):
2828
"""
2929

3030
def handle(self, *args, **options):
31-
with CommandHandler.command_handler(INSIGHTS_JOB_NAME):
31+
with CommandHandler.handle(INSIGHTS_JOB_NAME):
3232
logger.info("Retry Failed Message Batch Command started")
3333
queue = Queue.RetryMessageBatches()
3434
logger.debug("Retry queue items: %s", queue.peek())

manage_breast_screening/notifications/management/commands/save_message_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Command(BaseCommand):
2626
"""
2727

2828
def handle(self, *args, **options):
29-
with CommandHandler.command_handler(INSIGHTS_JOB_NAME):
29+
with CommandHandler.handle(INSIGHTS_JOB_NAME):
3030
logger.info("Save Message Status Command started")
3131
queue = Queue.MessageStatusUpdates()
3232
for item in queue.items():

manage_breast_screening/notifications/management/commands/send_message_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Command(BaseCommand):
3333
"""
3434

3535
def handle(self, *args, **options):
36-
with CommandHandler.command_handler(INSIGHTS_JOB_NAME):
36+
with CommandHandler.handle(INSIGHTS_JOB_NAME):
3737
return self.send_message_batch()
3838

3939
def send_message_batch(self):

manage_breast_screening/notifications/management/commands/store_mesh_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Command(BaseCommand):
2020
"""
2121

2222
def handle(self, *args, **options):
23-
with CommandHandler.command_handler(INSIGHTS_JOB_NAME):
23+
with CommandHandler.handle(INSIGHTS_JOB_NAME):
2424
logger.info("Store MESH Messages command started")
2525
today_dirname = datetime.today().strftime("%Y-%m-%d")
2626
with MeshInbox() as inbox:

manage_breast_screening/notifications/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ def mock_insights_logger(request, monkeypatch):
3838
@pytest.fixture
3939
def mock_command_handler(request, monkeypatch):
4040
mock_command_handler = MagicMock()
41-
monkeypatch.setattr(CommandHandler, "command_handler", mock_command_handler)
41+
monkeypatch.setattr(CommandHandler, "handle", mock_command_handler)
4242
return mock_command_handler

manage_breast_screening/notifications/tests/management/commands/helpers/test_command_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def test_command_handler_yields():
1212
mock = MagicMock()
13-
with CommandHandler.command_handler("SomeJob"):
13+
with CommandHandler.handle("SomeJob"):
1414
mock.do_stuff("this")
1515
mock.do_more_stuff("that")
1616

@@ -24,7 +24,7 @@ def test_command_handler_logs_and_raises(mock_insights_logger):
2424
mock.do_more_stuff.side_effect = an_exception
2525

2626
with pytest.raises(CommandError) as exc_info:
27-
with CommandHandler.command_handler("SomeJob"):
27+
with CommandHandler.handle("SomeJob"):
2828
mock.do_stuff("this")
2929
mock.do_more_stuff("that")
3030
mock_insights_logger.assert_called_once_with(f"SomeJobError: {an_exception}")
@@ -38,7 +38,7 @@ def test_command_handler_logs_and_raises(mock_insights_logger):
3838

3939
def test_command_handler_logs_success(mock_insights_logger):
4040
mock = MagicMock()
41-
with CommandHandler.command_handler("SomeJob"):
41+
with CommandHandler.handle("SomeJob"):
4242
mock.do_stuff("this")
4343
mock.do_more_stuff("that")
4444

0 commit comments

Comments
 (0)