# Path: dftimewolf/metawolf/output.py
# PURPLE = '\033[95m'
# GREEN = '\033[92m'
# BLUE = '\033[94m'
# YELLOW = '\033[93m'
# RED = '\033[91m'
# ENDC = '\033[0m'
# DFTIMEWOLF = 'dftimewolf'
# CRITICAL_ERROR = '] CRITICAL'
# PYTHON_ERROR = "Traceback (most recent call last):"
# class MetawolfOutput:
# class MetawolfProcess:
#   def Welcome(self) -> str:
#   def Color(value: Any, color: str, escape: bool = False) -> str:
#   def __init__(
#       self,
#       session_id: Optional[str] = None,
#       cmd: Optional[List[str]] = None,
#       output_id: Optional[int] = None,
#       from_dict: Optional[Dict[str, str]] = None,
#       metawolf_utils: Optional[utils.MetawolfUtils] = None
#   ) -> None:
#   def Run(self) -> None:
#   def Poll(self) -> Optional[int]:
#   def Status(self) -> str:
#   def Read(self, show_warning: bool = True) -> str:
#   def Send(self, value: str) -> None:
#   def Terminate(self) -> str:
#   def Marshal(self) -> Dict[str, Any]:


import unittest
import typing
from unittest import mock
from dftimewolf.metawolf import output
class MetawolfOutputTests(unittest.TestCase):
  """Test output.py"""

  def testColor(self) -> None:
    """Test that outputs are color formatted correctly."""
    colored_string = output.MetawolfOutput().Color('test_string', output.GREEN)
    expected_string = '\033[92mtest_string\033[0m'
    self.assertEqual(expected_string, colored_string)


class MetawolfProcessTest(unittest.TestCase):
  """Test output.py"""

  @mock.patch('dftimewolf.metawolf.output.MetawolfProcess.Read')
  @mock.patch('dftimewolf.metawolf.output.MetawolfProcess.Poll')
  @typing.no_type_check
  def testStatus(self, mock_poll, mock_read) -> None:
    """Test that the inferred process status is correct."""
    metawolf_process = output.MetawolfProcess(from_dict=MOCK_PROCESS_JSON)
    # In this test we use "assertIn" since the output contains terminal color
    # codes.

    mock_poll.return_value = None
    self.assertIn('Running', metawolf_process.Status())

    mock_poll.return_value = -1
    metawolf_process.status = None
    self.assertIn('Unknown', metawolf_process.Status())

    mock_poll.return_value = 1

# Path: dftimewolf/metawolf/output.py
# PURPLE = '\033[95m'
# GREEN = '\033[92m'
# BLUE = '\033[94m'
# YELLOW = '\033[93m'
# RED = '\033[91m'
# ENDC = '\033[0m'
# DFTIMEWOLF = 'dftimewolf'
# CRITICAL_ERROR = '] CRITICAL'
# PYTHON_ERROR = "Traceback (most recent call last):"
# class MetawolfOutput:
# class MetawolfProcess:
#   def Welcome(self) -> str:
#   def Color(value: Any, color: str, escape: bool = False) -> str:
#   def __init__(
#       self,
#       session_id: Optional[str] = None,
#       cmd: Optional[List[str]] = None,
#       output_id: Optional[int] = None,
#       from_dict: Optional[Dict[str, str]] = None,
#       metawolf_utils: Optional[utils.MetawolfUtils] = None
#   ) -> None:
#   def Run(self) -> None:
#   def Poll(self) -> Optional[int]:
#   def Status(self) -> str:
#   def Read(self, show_warning: bool = True) -> str:
#   def Send(self, value: str) -> None:
#   def Terminate(self) -> str:
#   def Marshal(self) -> Dict[str, Any]:


# Path: tests/metawolf/output.py
import unittest
import typing
from unittest import mock
from dftimewolf.metawolf import output

class MetawolfOutputTests(unittest.TestCase):
  """Test output.py"""

  def testColor(self) -> None:
    """Test that outputs are color formatted correctly."""
    colored_string = output.MetawolfOutput().Color('test_string', output.GREEN)
    expected_string = '\033[92mtest_string\033[0m'
    self.assertEqual(expected_string, colored_string)


class MetawolfProcessTest(unittest.TestCase):
  """Test output.py"""

  @mock.patch('dftimewolf.metawolf.output.MetawolfProcess.Read')
  @mock.patch('dftimewolf.metawolf.output.MetawolfProcess.Poll')
  @typing.no_type_check
  def testStatus(self, mock_poll, mock_read) -> None:
    """Test that the inferred process status is correct."""
    metawolf_process = output.MetawolfProcess(from_dict=MOCK_PROCESS_JSON)
    # In this test we use "assertIn" since the output contains terminal color
    # codes.

    mock_poll.return_value = None
    self.assertIn('Running', metawolf_process.Status())

    mock_poll.return_value = -1
    metawolf_process.status = None
    self.assertIn('Unknown', metawolf_process.Status())

    mock_poll.return_value = 1

    mock_read.return_value = output.CRITICAL_ERROR