From ca3ed6f2c954649429275d544f3e48a00ab4905a Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 16 Feb 2021 16:16:33 +0300 Subject: Add new test cases for run_cmd --- tests/unit/test_commands.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/test_commands.py b/tests/unit/test_commands.py index a1ac6eb..b0c217d 100644 --- a/tests/unit/test_commands.py +++ b/tests/unit/test_commands.py @@ -8,6 +8,7 @@ from typing import Callable from unittest import mock from gn3.commands import compose_gemma_cmd from gn3.commands import queue_cmd +from gn3.commands import run_cmd from gn3.exceptions import RedisConnectionError @@ -70,3 +71,13 @@ class TestCommands(unittest.TestCase): mock.call("status", "queued", actual_unique_id)]) mock_redis_conn.rpush.assert_has_calls( [mock.call("GN2::job-queue", actual_unique_id)]) + + def test_run_cmd_correct_input(self): + """Test that a correct cmd is processed correctly""" + self.assertEqual(run_cmd("echo test"), + {"code": 0, "output": "test\n"}) + + def test_run_cmd_incorrect_input(self): + """Test that an incorrect cmd is processed correctly""" + result = run_cmd("echoo test") + self.assertEqual(127, result.get("code")) -- cgit v1.2.3