예제 #1
0
    def test_manual_enabling(self):
        """
        Test that enabling the logging manually works
        """
        logger = IgnisLogging().get_logger(__name__)
        logger.enable_file_logging()
        logger.log_to_file(test="test")

        self.assertTrue(os.path.exists(self._default_log))
예제 #2
0
    def test_save_line(self):
        """
        Test basic log operations
        """
        logger = IgnisLogging().get_logger(__name__)

        logger.enable_file_logging()
        logger.log_to_file(test="test")

        self.assertTrue(os.path.exists(self._default_log))
        with open(self._default_log, 'r') as file:
            self.assertIn("\'test\':\'test\'", file.read())
예제 #3
0
    def test_format(self):
        """
        Test format of the saved line
        """
        logger = IgnisLogging().get_logger(__name__)

        logger.enable_file_logging()
        logger.log_to_file(test="test")

        with open(self._default_log, 'r') as file:
            self.assertRegex(
                file.read(),
                r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} ignis_logging \S+")
예제 #4
0
    def test_multiple_lines(self):
        """
        Test logging multiple lines
        """
        logger = IgnisLogging().get_logger(__name__)

        logger.enable_file_logging()
        logger.log_to_file(test="test1")
        logger.log_to_file(test="test2")

        with open(self._default_log, 'r') as file:
            lines = file.read().split('\n')

        self.assertGreaterEqual(len(lines), 2)