Skip to content
Snippets Groups Projects
Commit 246ac12c authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Small changes to monitor and test_monitor

parent 7926ea30
No related branches found
No related tags found
No related merge requests found
......@@ -239,26 +239,7 @@ def main():
# Parse command-line args
args = make_arg_parser().parse_args()
monitor = WorkflowMonitor(args.log_path)
with workflow_events as wfe:
decorated_send = log_decorator_factory('Sending event...')(workflow_events.send)
with workflow_events:
for event in monitor.events:
wfe.send(event, WORKFLOW_STATUS_EXCH)
# # Probably want to refactor this so that it doesn't create its own connection just for this,
# # since creating connections is expensive
# decorated_connect = log_decorator_factory('Making connection...')(make_amqp_connection)
# decorated_config_channel = log_decorator_factory('Configuring channel...')(configure_amqp_channel)
# decorated_emit = log_decorator_factory('Emitting message...')(emit_amqp_message)
#
# with decorated_connect(args.profile) as connection:
# with decorated_config_channel(
# connection=connection,
# exchange=WORKFLOW_STATUS_EXCH,
# exchange_type='topic'
# ) as channel:
# for event in monitor.events:
# decorated_emit(
# channel=channel,
# exchange=WORKFLOW_STATUS_EXCH,
# routing_key=f'{event.job_name}.{event.job_id}.{event.type.name.lower()}',
# msg=event.json()
# )
decorated_send(event, WORKFLOW_STATUS_EXCH)
......@@ -80,8 +80,8 @@ def test_monitor_events(mocker: MockerFixture):
]
[mocker.patch(mock) for mock in mock_list]
channel = workflow_events
for event in WorkflowMonitor(log_path).events:
channel.send(event, WORKFLOW_STATUS_EXCH)
with workflow_events as wfe:
for event in WorkflowMonitor(log_path).events:
wfe.send(event, WORKFLOW_STATUS_EXCH)
assert channel.send.call_count == 8
assert wfe.send.call_count == 8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment