aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_commands.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-03-08 08:07:38 +0300
committerFrederick Muriuki Muriithi2022-03-08 08:07:38 +0300
commite30f9a9b746f7dcdc8707e66cc65e580e6f83f47 (patch)
tree2edbbe2ff8957daf22ec60a562a633bdfa064723 /tests/unit/test_commands.py
parenteae345ed252c01e541d64c7e5b60b488d84268c6 (diff)
downloadgenenetwork3-e30f9a9b746f7dcdc8707e66cc65e580e6f83f47.tar.gz
Fix tests, and issues caught by tests
Fix some issues caught by tests due to changes introducing the hand-off of the partial correlations computations to an external process Fix some issues due to the changes that introduce context managers for database connections Update some tests to take the above two changes into consideration
Diffstat (limited to 'tests/unit/test_commands.py')
-rw-r--r--tests/unit/test_commands.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/unit/test_commands.py b/tests/unit/test_commands.py
index e0efaf7..4dd8735 100644
--- a/tests/unit/test_commands.py
+++ b/tests/unit/test_commands.py
@@ -96,8 +96,7 @@ class TestCommands(unittest.TestCase):
@pytest.mark.unit_test
@mock.patch("gn3.commands.datetime")
@mock.patch("gn3.commands.uuid4")
- def test_queue_cmd_correct_calls_to_redis(self, mock_uuid4,
- mock_datetime):
+ def test_queue_cmd_correct_calls_to_redis(self, mock_uuid4, mock_datetime):
"""Test that the cmd is queued properly"""
mock_uuid4.return_value = 1234
mock_datetime.now.return_value = datetime.fromisoformat('2021-02-12 '
@@ -112,7 +111,7 @@ class TestCommands(unittest.TestCase):
job_queue="GN2::job-queue"),
actual_unique_id)
mock_redis_conn.hset.assert_has_calls(
- [mock.call(name=actual_unique_id, key="cmd", value="ls"),
+ [mock.call(name=actual_unique_id, key="cmd", value='"ls"'),
mock.call(name=actual_unique_id, key="result", value=""),
mock.call(name=actual_unique_id, key="status", value="queued")])
mock_redis_conn.rpush.assert_has_calls(
@@ -139,23 +138,23 @@ class TestCommands(unittest.TestCase):
email="me@me.com"),
actual_unique_id)
mock_redis_conn.hset.assert_has_calls(
- [mock.call(name=actual_unique_id, key="cmd", value="ls"),
+ [mock.call(name=actual_unique_id, key="cmd", value='"ls"'),
mock.call(name=actual_unique_id, key="result", value=""),
mock.call(name=actual_unique_id, key="status", value="queued"),
mock.call(name=actual_unique_id, key="email", value="me@me.com")
- ])
+ ], any_order=True)
mock_redis_conn.rpush.assert_has_calls(
[mock.call("GN2::job-queue", actual_unique_id)])
@pytest.mark.unit_test
def test_run_cmd_correct_input(self):
"""Test that a correct cmd is processed correctly"""
- self.assertEqual(run_cmd("echo test"),
+ self.assertEqual(run_cmd('"echo test"'),
{"code": 0, "output": "test\n"})
@pytest.mark.unit_test
def test_run_cmd_incorrect_input(self):
"""Test that an incorrect cmd is processed correctly"""
- result = run_cmd("echoo test")
+ result = run_cmd('"echoo test"')
self.assertEqual(127, result.get("code"))
self.assertIn("not found", result.get("output"))