Skip to content

Commit

Permalink
Merge pull request #52 from ESIPFed/update/test-detail
Browse files Browse the repository at this point in the history
updated test detail for fixing detail command
  • Loading branch information
saikiranAnnam authored Dec 17, 2024
2 parents a3495d6 + 1b17de8 commit 4a8e3d2
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions test/test_detail.py
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
)


0 comments on commit 4a8e3d2

Please sign in to comment.