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

Added comments to test_wf_monitor

parent 553f94ca
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,10 @@ WORKFLOW_STATUS_EXCH = 'workspaces.workflow-service.workflow-status'
def test_read_log():
"""
Tests whether or not the example log is being correctly read by checking for strings known to
exist in the example log file
"""
test_strs = [
'Image size of job updated: 432',
'432 - ResidentSetSize of job (KB)',
......@@ -22,7 +26,10 @@ def test_read_log():
assert s in test_monitor.log
def test_read_log_timeout(capsys):
def test_read_log_timeout():
"""
Tests the timeout functionality of WorkflowMonitor.read_htcondor_log()
"""
with pytest.raises(SystemExit) as sys_ex:
WorkflowMonitor('logs/file-that-does-not-exist.txt', 1)
assert sys_ex.type == SystemExit
......@@ -30,6 +37,10 @@ def test_read_log_timeout(capsys):
def test_parse_log():
"""
Tests that the example log file is correctly parsed by checking for the known order of event
types
"""
test_event_types = [
WorkflowEventType.SUBMITTED,
WorkflowEventType.EXECUTING,
......@@ -45,12 +56,23 @@ def test_parse_log():
def test_parse_log_error():
"""
Tests that WorkflowMonitor.parse_log() correctly raises a ValueError when a badly formatted
log is parsed
"""
with pytest.raises(ValueError) as val_err:
WorkflowMonitor('logs/test.log')
assert val_err.type == ValueError
def test_monitor_events(mocker: MockerFixture):
"""
Test that mocks the core wf_monitor functionality of creating a connection to the RabbitMQ
server, configuring a channel with that connection, and emitting events through that channel
:param mocker: Pytest fixture from pytest_mock that wraps the real function and mimics that
its been called as normal; allows for testing interaction with the server without actually
requiring a connection to the server
"""
mock_list = [
'pika.adapters.blocking_connection.BlockingChannel.basic_publish',
'channels.amqp_helpers.make_amqp_connection',
......
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