Skip to content

Commit

Permalink
Mock the exit status 0 for all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrtalbot committed Apr 25, 2024
1 parent 982a461 commit 382454f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion seqerakit/seqeraplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _execute_command(self, full_cmd, to_json=False):
stdout = stdout.decode("utf-8").strip()

if "ERROR: " in stdout or process.returncode != 0:
self._handle_command_errors(stdout)
self._handle_command_errors(str(stdout))

return json.loads(stdout) if to_json else stdout

Expand Down
6 changes: 5 additions & 1 deletion tests/unit/test_seqeraplatform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from unittest.mock import patch
from unittest.mock import MagicMock, patch
from seqerakit import seqeraplatform
import json
import subprocess
Expand All @@ -26,6 +26,7 @@ def test_run_with_jsonout_command(self, mock_subprocess):
"dateCreated": "2023-02-15T13:14:30Z",
}
# Mock the stdout of the Popen process
mock_subprocess.return_value = MagicMock(returncode=0)
mock_subprocess.return_value.communicate.return_value = (
json.dumps(mock_pipelines_json).encode(),
b"",
Expand Down Expand Up @@ -93,6 +94,7 @@ def test_resource_creation_error(self):
def test_json_parsing(self):
with patch("subprocess.Popen") as mock_subprocess:
# Mock the stdout of the Popen process to return JSON
mock_subprocess.return_value = MagicMock(returncode=0)
mock_subprocess.return_value.communicate.return_value = (
b'{"key": "value"}',
b"",
Expand All @@ -112,6 +114,7 @@ def setUp(self):
@patch("subprocess.Popen")
def test_cli_args_inclusion(self, mock_subprocess):
# Mock the stdout of the Popen process
mock_subprocess.return_value = MagicMock(returncode=0)
mock_subprocess.return_value.communicate.return_value = (
json.dumps({"key": "value"}).encode(),
b"",
Expand All @@ -136,6 +139,7 @@ def test_cli_args_inclusion_ssl_certs(self, mock_subprocess):
seqeraplatform.SeqeraPlatform(cli_args=self.cli_args)

# Mock the stdout of the Popen process
mock_subprocess.return_value = MagicMock(returncode=0)
mock_subprocess.return_value.communicate.return_value = (
json.dumps({"key": "value"}).encode(),
b"",
Expand Down

0 comments on commit 382454f

Please sign in to comment.