def test_with_multiple_reinsurance_subfolders(self, targets):
        with TemporaryDirectory() as d:
            os.mkdir(os.path.join(d, 'RI_1'))
            os.mkdir(os.path.join(d, 'RI_2'))

            for target in targets:
                with io.open(os.path.join(d, target), 'w',
                             encoding='utf-8') as f:
                    f.write(target)
                with io.open(os.path.join(d, 'RI_1', target),
                             'w',
                             encoding='utf-8') as f:
                    f.write(target)
                with io.open(os.path.join(d, 'RI_2', target),
                             'w',
                             encoding='utf-8') as f:
                    f.write(target)

            create_binary_tar_file(d)

            all_targets = copy(targets)
            for t in targets:
                # tarfile converts os-specific separators to forward slashes
                all_targets.append("RI_1/{}".format(t))
                all_targets.append("RI_2/{}".format(t))

            with tarfile.open(os.path.join(d, TAR_FILE),
                              'r:gz',
                              encoding='utf-8') as tar:
                self.assertEqual(len(all_targets), len(tar.getnames()))
                self.assertEqual(set(all_targets), set(tar.getnames()))
Exemplo n.º 2
0
    def test_directory_only_contains_excluded_files___tar_is_empty(self):
        with TemporaryDirectory() as d:
            with io.open(os.path.join(d, 'another_file'), 'w', encoding='utf-8') as f:
                f.write('file data')

            create_binary_tar_file(d)

            with tarfile.open(os.path.join(d, TAR_FILE), 'r:gz', encoding='utf-8') as tar:
                self.assertEqual(0, len(tar.getnames()))
Exemplo n.º 3
0
    def test_directory_contains_some_target_files___target_files_are_included(self, targets):
        with TemporaryDirectory() as d:
            for target in targets:
                with io.open(os.path.join(d, target), 'w', encoding='utf-8') as f:
                    f.write(target)

            create_binary_tar_file(d)

            with tarfile.open(os.path.join(d, TAR_FILE), 'r:gz', encoding='utf-8') as tar:
                self.assertEqual(len(targets), len(tar.getnames()))
                self.assertEqual(set(targets), set(tar.getnames()))
Exemplo n.º 4
0
    def test_with_single_reinsurance_subfolder(self, targets):
        with TemporaryDirectory() as d:
            os.mkdir(os.path.join(d, 'RI_1'))
            for target in targets:
                with io.open(os.path.join(d, target), 'w', encoding='utf-8') as f:
                    f.write(target)
                with io.open(os.path.join(d, 'RI_1', target), 'w', encoding='utf-8') as f:
                    f.write(target)

            create_binary_tar_file(d)

            all_targets = copy(targets)
            for t in targets:
                all_targets.append("RI_1{}{}".format(os.sep, t))

            with tarfile.open(os.path.join(d, TAR_FILE), 'r:gz', encoding='utf-8') as tar:
                self.assertEqual(len(all_targets), len(tar.getnames()))
                self.assertEqual(set(all_targets), set(tar.getnames()))