def test_stderr_only(self):
        """Verifies logging only to stderr works."""
        config.CONFIG[config_constants.DEBUG] = True
        config.CONFIG[config_constants.LOG] = False
        configure_logging.configure_logging()

        test_message1 = "Here is the first test"
        with self.capture(logger.LOGGER.info, test_message1) as output:
            self.assertTrue(test_message1 in output)
            self.assertTrue("INFO" in output)

        with open(ConfigureLoggingTest.LOG_FILE, "r") as log_file:
            output = log_file.read()
            self.assertTrue(test_message1 not in output)
            self.assertTrue("INFO" not in output)
    def test_no_logging_except_errors(self):
        """Verifies that only errors are logging when no logging specified"""
        config.CONFIG[config_constants.DEBUG] = False
        config.CONFIG[config_constants.LOG] = False
        configure_logging.configure_logging()

        test_message1 = "Here is the first test"
        with self.capture(logger.LOGGER.info, test_message1) as output:
            self.assertTrue(test_message1 not in output)
            self.assertTrue("INFO" not in output)

        with self.capture(logger.LOGGER.error, test_message1) as output:
            self.assertTrue(test_message1 in output)
            self.assertTrue("ERROR" in output)

        with open(ConfigureLoggingTest.LOG_FILE, "r") as log_file:
            output = log_file.read()
            self.assertTrue(test_message1 not in output)
            self.assertTrue("INFO" not in output)
            self.assertTrue("ERROR" not in output)
Example #3
0
import os
from src.config import config
from src.scripts import configure_logging

config.load_config(os.path.dirname(__file__) + "/../src/config/test.json")
configure_logging.configure_logging()
Example #4
0
 def tearDownClass(cls):
     # Delete the database each time to start fresh.
     config.CONFIG = cls.old_config
     configure_logging.configure_logging()
Example #5
0
 def setUpClass(cls):
     # Make sure that the database is clean before this class is run.
     cls.old_config = config.CONFIG
     config.load_config(os.path.dirname(__file__) + "/../../src/config/staging.json")
     configure_logging.configure_logging()
     load_data.load_data()