Ejemplo n.º 1
0
    def test_no_day(self, log_directory):
        logger = GZipFileLogger()
        stream = 'first'
        logger.log_line(stream, first_line)
        logger.log_line(stream, second_line)
        logger.close()

        log_filename = GZipFileLogger.get_filename(stream)
        content = self._open_and_remove(log_filename)
        assert content == complete_line
Ejemplo n.º 2
0
    def test_no_day(self):
        logger = GZipFileLogger()
        stream = 'first'
        logger.log_line(stream, first_line)
        logger.log_line(stream, second_line)
        logger.close()

        log_filename = GZipFileLogger.get_filename(stream)
        content = self._open_and_remove(log_filename)
        T.assert_equal(content, complete_line)
Ejemplo n.º 3
0
    def test_no_day(self, log_directory):
        logger = GZipFileLogger()
        stream = 'first'
        logger.log_line(stream, first_line)
        logger.log_line(stream, second_line)
        logger.close()

        log_filename = GZipFileLogger.get_filename(stream)
        content = self._open_and_remove(log_filename)
        assert content == complete_line
Ejemplo n.º 4
0
    def test_single_day(self, log_directory):
        stream = 'second'
        day = date.today()
        logger = GZipFileLogger(day=day)
        logger.log_line(stream, first_line)
        logger.log_line(stream, second_line)
        logger.close()

        log_filename = GZipFileLogger.get_filename(stream, day=day)
        content = self._open_and_remove(log_filename)
        assert content == complete_line
Ejemplo n.º 5
0
    def test_single_day(self, log_directory):
        stream = 'second'
        day = date.today()
        logger = GZipFileLogger(day=day)
        logger.log_line(stream, first_line)
        logger.log_line(stream, second_line)
        logger.close()

        log_filename = GZipFileLogger.get_filename(stream, day=day)
        content = self._open_and_remove(log_filename)
        assert content == complete_line
Ejemplo n.º 6
0
    def test_cant_open_stream(self, capsys):
        log_dir = os.path.join(self.log_dir, 'non_existent_directory')
        with staticconf.testing.MockConfiguration(log_dir=log_dir, namespace='clog'):
            logger = GZipFileLogger()
            stream = 'first'
            with pytest.raises(IOError):
                logger.log_line(stream, first_line)

            stdout, stderr = capsys.readouterr()
            assert stderr == 'Unable to open file for stream first in directory {0}\n'.format(
                log_dir
            )
Ejemplo n.º 7
0
    def test_multi_day(self, log_directory):
        stream = 'multi'
        first_day = date.today()
        second_day = date.today() + timedelta(days=1)

        for day in (first_day, second_day):
            logger = GZipFileLogger(day=day)
            logger.log_line(stream, first_line)
            logger.log_line(stream, second_line)
            logger.close()

        for day in (first_day, second_day):
            log_filename = GZipFileLogger.get_filename(stream, day=day)
            content = self._open_and_remove(log_filename)
            assert content == complete_line
Ejemplo n.º 8
0
    def test_multi_day(self, log_directory):
        stream = 'multi'
        first_day = date.today()
        second_day = date.today() + timedelta(days=1)

        for day in (first_day, second_day):
            logger = GZipFileLogger(day=day)
            logger.log_line(stream, first_line)
            logger.log_line(stream, second_line)
            logger.close()

        for day in (first_day, second_day):
            log_filename = GZipFileLogger.get_filename(stream, day=day)
            content = self._open_and_remove(log_filename)
            assert content == complete_line