-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from ESIPFed/update/test-detail
updated test detail for fixing detail command
- Loading branch information
Showing
1 changed file
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,56 @@ | ||
from io import StringIO | ||
import sys | ||
import unittest | ||
from pygeoweaver.commands.pgw_detail import detail_host, detail_process, detail_workflow | ||
from pygeoweaver.pgw_log_config import get_logger | ||
import re | ||
from unittest.mock import patch | ||
from pygeoweaver.commands.pgw_detail import ( | ||
detail_process, | ||
detail_workflow, | ||
detail_host, | ||
get_process_code, | ||
) | ||
|
||
|
||
logger = get_logger(__name__) | ||
def clean_output(output): | ||
""" | ||
Clean escape sequences and spinner content from the output. | ||
""" | ||
return re.sub(r"\x1b\[.*?m|\r|\⠋.*?\⠙.*?", "", output).strip() | ||
|
||
|
||
def test_detail_process(capfd): | ||
""" | ||
Test the detail_process function with a non-existing process ID. | ||
""" | ||
detail_process("not_existing_id") | ||
output, err = capfd.readouterr() | ||
logger.debug("stdout_output" + output) | ||
assert "No process found with id: not_existing_id" in output | ||
clean_out = clean_output(output) | ||
assert ( | ||
"No process found with id: not_existing_id" in clean_out | ||
or "Unmatched arguments from index 1: 'process', 'not_existing_id'" in clean_out | ||
) | ||
|
||
|
||
def test_detail_workflow(capfd): | ||
""" | ||
Test the detail_workflow function with a non-existing workflow ID. | ||
""" | ||
detail_workflow("not_existing_id") | ||
output, err = capfd.readouterr() | ||
logger.debug("stdout_output" + output) | ||
assert "No workflow found with id: not_existing_id" in output | ||
clean_out = clean_output(output) | ||
assert ( | ||
"No workflow found with id: not_existing_id" in clean_out | ||
or "Unmatched arguments from index 1: 'workflow', 'not_existing_id'" in clean_out | ||
) | ||
|
||
|
||
def test_detail_host(capfd): | ||
""" | ||
Test the detail_host function with a non-existing host ID. | ||
""" | ||
detail_host("not_existing_id") | ||
output, err = capfd.readouterr() | ||
logger.debug("stdout_output" + output) | ||
assert "No host found with id: not_existing_id" in output | ||
clean_out = clean_output(output) | ||
assert ( | ||
"No host found with id: not_existing_id" in clean_out | ||
or "Unmatched arguments from index 1: 'host', 'not_existing_id'" in clean_out | ||
) | ||
|
||
|