Beispiel #1
0
 def test_zips_in_different_folders(self):
     with TempDirectory() as td:
         td.write('test', self.empty)
         td.write('log/test', self.empty)
         gzip_logs(td.path)
         td.compare(['test', 'log/test', 'test.0.gz', 'log/test.0.gz'],
                    files_only=True)
Beispiel #2
0
    def test_more_renames(self):
        with TempDirectory() as td:
            td.write('test', self.empty)
            gzip_logs(td.path)
            gzip_logs(td.path)

            td.compare(['test', 'test.0.gz', 'test.1.gz'], files_only=True)
Beispiel #3
0
    def test_zip_subfolder(self):
        with TempDirectory() as td:
            td.makedir('log')
            td.write('log/test', self.empty)

            gzip_logs(td.path)
            td.compare([
                'log/test',
                'log/test.0.gz',
            ], files_only=True)
Beispiel #4
0
 def get_td_zipped_twice(self):
     '''Zip the same filenames twice
        with different content
     '''
     td = TempDirectory()
     td.write('file.1', b'1')
     td.write('file.2', b'2')
     gzip_logs(td.path)
     td.write('file.1', b'3')
     td.write('file.2', b'4')
     gzip_logs(td.path)
     return td
Beispiel #5
0
    def test_more_files(self):
        with TempDirectory() as td:
            td.write('test1', self.empty)
            td.write('test2', self.empty)
            td.write('test3', self.empty)

            gzip_logs(td.path)
            td.compare([
                'test1', 'test2', 'test3', 'test1.0.gz', 'test2.0.gz',
                'test3.0.gz'
            ],
                       files_only=True)
Beispiel #6
0
    def test_sorted_nums(self):
        with TempDirectory() as td:
            td.write('file3.1', b'1')
            td.write('file3.2', b'2')
            gzip_logs(td.path)
            td.write('file3.1', b'3')
            td.write('file3.2', b'4')
            gzip_logs(td.path)

            td.compare([
                'file3.1', 'file3.2', 'file3.1.gz', 'file3.2.gz', 'file3.3.gz',
                'file3.4.gz'
            ],
                       files_only=True)
Beispiel #7
0
    def test_sorted_content_nums(self):
        with TempDirectory() as td:
            td.write('file3.1', b'1')
            td.write('file3.2', b'2')
            gzip_logs(td.path)
            td.write('file3.1', b'3')
            td.write('file3.2', b'4')
            gzip_logs(td.path)

            gz1_cont = self.read_gzip(os.path.join(td.path, 'file3.1.gz'))
            gz2_cont = self.read_gzip(os.path.join(td.path, 'file3.2.gz'))
            gz3_cont = self.read_gzip(os.path.join(td.path, 'file3.3.gz'))
            gz4_cont = self.read_gzip(os.path.join(td.path, 'file3.4.gz'))

            self.assertEqual(gz1_cont, b'1')
            self.assertEqual(gz2_cont, b'2')
            self.assertEqual(gz3_cont, b'3')
            self.assertEqual(gz4_cont, b'4')
Beispiel #8
0
 def test_non_recursive(self):
     with TempDirectory() as td:
         td.write('log/file', self.empty)
         td.write('file', self.empty)
         gzip_logs(td.path, non_recursive=True)
         td.compare(['log/file', 'file', 'file.0.gz'], files_only=True)
Beispiel #9
0
 def test_consecutive_zips(self):
     with TempDirectory() as td:
         td.write('file', self.empty)
         gzip_logs(td.path)
         gzip_logs(td.path)
         td.compare(['file', 'file.0.gz', 'file.1.gz'], files_only=True)