diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/test_commands.py | 13 | ||||
-rw-r--r-- | tests/unit/test_db_utils.py | 2 |
2 files changed, 6 insertions, 9 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")) diff --git a/tests/unit/test_db_utils.py b/tests/unit/test_db_utils.py index 96ee68f..44d6703 100644 --- a/tests/unit/test_db_utils.py +++ b/tests/unit/test_db_utils.py @@ -27,8 +27,6 @@ class TestDatabase(TestCase): mock_sql.connect.assert_called_with( "localhost", "guest", "4321", "users") - self.assertIsInstance( - results, tuple, "database not created successfully") @pytest.mark.unit_test @mock.patch("gn3.db_utils.SQL_URI", |