def test_determine_project(self): filename = inspect.stack()[-1].filename expected_file_path = os.path.sep.join(filename.split(os.path.sep)[:-1]) returned_file_path = Logger.determine_project() print(f"FILE: {filename}") print(f"EXPECTED PATH: {expected_file_path}") print(f"RETURNED PATH: {expected_file_path}") assert_equals(returned_file_path, expected_file_path)
def test_basic_logger(self): logger = Logger() # Remove the file extension from the file, and transform into dotted path notation expected_logger_name = ".".join(__file__.split('.')[0].split(os.path.sep)) assert_equals(logger.loglevel, Logger.DEFAULT_LOG_LEVEL) assert_false(logger.root) assert_is_none(logger.filename) assert_equals(logger.project, logger.DEFAULT_PROJECT) assert_equals(logger.name, expected_logger_name) assert_true(isinstance(logger.logger, ContextAdapter))
def _test_logging_level(level: str) -> None: """ Invokes logging method based on level. Args: level (str): name of logging level Returns: None """ logger = Logger() log_method = getattr(logger, level.lower()) log_method(f"This is a test for logger level {level.upper()}. " f"This should not crash or throw an error.")
from random import choice from typing import List, NoReturn from uuid import uuid4 from flowtester.logging.logger import Logger from flowtester.state_machine.engine.input import PathStep from nose.tools import assert_equals, assert_true logging = Logger() class TestPathStep: TRIGGER_NAME = 'TEST' def test__str__does_not_crash(self): test_id = str(uuid4()) validation_ids = ['test'] expectations = [False] step = PathStep(trigger=self.TRIGGER_NAME) step.add_id(step_id=test_id) self._add_and_validate_expectations( validation_ids=validation_ids, expectations=expectations) assert_true(isinstance(str(step), str)) def test_add_id(self):
def display_input_files(log: logger.Logger, model_file: str, test_file: str, ts_name: str, tc_name: str, log_file: str) -> None: """ Logs configuration information about current execution. Args: log (logger.Logger) : Instantiated logger model_file (str): Name/Path of state machine definition file test_file (str): Name/Path of test definition file ts_name (str): Name of test suite tc_name (str): Name of test case log_file (str): Name of log file Returns: None """ border = f"+{'-' * 100}" log.info(border) log.info(f"| STATE MODEL: {os.path.abspath(model_file)}") log.info(border) log.info(f"| TEST FILE: {os.path.abspath(test_file)}") log.info(f"| TEST SUITE: {ts_name}") log.info(f"| TEST CASE: {tc_name}") log.info(border) log.info(f"| LOG FILE: {log_file}") log.info(border)
def test_logger__method_with_project_options_set_to_none(self): self._test_logging_object__method(project=None, logger_obj=Logger())
def test_logger__method_with_custom_project_options(self): self._test_logging_object__method(project='tests', logger_obj=Logger())