From eaee0aa2f11c7b54e2c4e2830f4afaaa69eb4180 Mon Sep 17 00:00:00 2001
From: nhertz <nhertz@nrao.edu>
Date: Wed, 9 Sep 2020 14:00:44 -0600
Subject: [PATCH] Added comments to test_wf_monitor

---
 .../wf_monitor/test/test_wf_monitor.py        | 24 ++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/apps/cli/utilities/wf_monitor/test/test_wf_monitor.py b/apps/cli/utilities/wf_monitor/test/test_wf_monitor.py
index 7f0cf4e95..f0f13d281 100644
--- a/apps/cli/utilities/wf_monitor/test/test_wf_monitor.py
+++ b/apps/cli/utilities/wf_monitor/test/test_wf_monitor.py
@@ -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',
-- 
GitLab