Exemplo n.º 1
0
    def test_init(self):
        """Test LogConnection() initialisation."""

        # Path to log file.
        prefix = os.path.join(TMP_PATH, 'unittest')

        # Create logging object with connection/message.
        LogConnection(prefix, UnitTestMessageA.connection)
        LogConnection(prefix, UnitTestMessageA)

        # Ensure object can be initialised using all keyword arguments.
        max_entries = 10
        max_time = 60
        logger = LogConnection(prefix,
                               UnitTestMessageA,
                               time_origin=datetime.datetime.now(),
                               max_entries=max_entries,
                               max_time=max_time,
                               open_init=False)

        self.assertEqual(logger.max_entries, max_entries)
        self.assertEqual(logger.max_time, max_time)
        self.assertFalse(logger.is_alive())
        self.assertTrue(logger.open())
        self.assertFalse(logger.open())
        self.assertTrue(logger.close())
        self.assertFalse(logger.is_alive())
        self.assertFalse(logger.close())
Exemplo n.º 2
0
    def test_init(self):
        """Test LogConnection() initialisation."""

        # Path to log file.
        prefix = os.path.join(TMP_PATH, 'unittest')

        # Create logging object with connection/message.
        LogConnection(prefix, UnitTestMessageA.connection)
        LogConnection(prefix, UnitTestMessageA)

        # Ensure object can be initialised using all keyword arguments.
        max_entries = 10
        max_time = 60
        logger = LogConnection(prefix,
                               UnitTestMessageA,
                               time_origin=datetime.datetime.now(),
                               max_entries=max_entries,
                               max_time=max_time,
                               open_init=False)

        self.assertEqual(logger.max_entries, max_entries)
        self.assertEqual(logger.max_time, max_time)
        self.assertFalse(logger.is_alive())
        self.assertTrue(logger.open())
        self.assertFalse(logger.open())
        self.assertTrue(logger.close())
        self.assertFalse(logger.is_alive())
        self.assertFalse(logger.close())
Exemplo n.º 3
0
    def test_open_after_init(self):
        """Test LogConnection() start logging after initialisation."""

        prefix = os.path.join(TMP_PATH, 'unittest')
        logger = LogConnection(prefix, UnitTestMessageA, open_init=True)
        self.assertTrue(logger.is_alive())
        self.assertTrue(logger.close())
Exemplo n.º 4
0
    def test_open_after_init(self):
        """Test LogConnection() start logging after initialisation."""

        prefix = os.path.join(TMP_PATH, 'unittest')
        logger = LogConnection(prefix, UnitTestMessageA, open_init=True)
        self.assertTrue(logger.is_alive())
        self.assertTrue(logger.close())