Esempio n. 1
0
    def test_check_gul_and_il_and_single_ri_directory_structure_binaries_fail(self):
        with TemporaryDirectory() as d:
            for p in INPUT_FILES.values():
                Path(os.path.join(d, p['name'] + '.csv')).touch()
                Path(os.path.join(d, p['name'] + '.bin')).touch()
            os.mkdir(os.path.join(d, "RI_1"))
            for p in INPUT_FILES.values():
                Path(os.path.join(d, "RI_1", p['name'] + '.csv')).touch()
                Path(os.path.join(d, "RI_1", p['name'] + '.bin')).touch()

            with self.assertRaises(OasisException):
                check_inputs_directory(d, il=True, ri=True, check_binaries=True)
Esempio n. 2
0
 def test_check_gul_and_il_and_single_ri_directory_structure(self):
     with TemporaryDirectory() as d:
         for p in INPUT_FILES.values():
             Path(os.path.join(d, p['name'] + '.csv')).touch()
         os.mkdir(os.path.join(d, "RI_1"))
         for p in INPUT_FILES.values():
             f = os.path.join(d, "RI_1", p['name'] + '.csv')
             Path(f).touch()
         try:
             check_inputs_directory(d, il=True, ri=True, check_binaries=True)
         except Exception as e:
             self.fail('Exception was raised {}: {}'.format(type(e), e))
Esempio n. 3
0
    def test_il_is_true_bin_files_are_present_but_check_bin_files_are_true___no_exception_is_raised(self):
        with TemporaryDirectory() as d:
            for p in INPUT_FILES.values():
                Path(os.path.join(d, p['name'] + '.csv')).touch()

            for p in INPUT_FILES.values():
                Path(os.path.join(d, p['name'] + '.bin')).touch()

            try:
                check_inputs_directory(d, il=True, check_binaries=False)
            except Exception as e:
                self.fail('Exception was raised {}: {}'.format(type(e), e))
Esempio n. 4
0
def tar_file_targets(min_size=0):
    return lists(
        sampled_from(
            [target['name'] + '.bin' for target in INPUT_FILES.values()]),
        min_size=min_size,
        unique=True,
    )
Esempio n. 5
0
    def test_all_files_are_present_check_il_is_true___result_is_true(self):
        with TemporaryDirectory() as d:
            tar_file_name = os.path.join(d, 'exposures.tar')

            with tarfile.open(tar_file_name, 'w', encoding='utf-8') as tar:
                for f in INPUT_FILES.values():
                    Path(os.path.join(d, '{}.bin'.format(f['name']))).touch()

                tar.add(d, arcname='/')

            self.assertTrue(check_binary_tar_file(tar_file_name, check_il=True))
    def test_output_and_bin_input_files_are_removed(self):
        with TemporaryDirectory() as d:
            Path(os.path.join(d, TAR_FILE)).touch()

            for f in INPUT_FILES.values():
                Path(os.path.join(d, f['name'] + '.bin')).touch()

            cleanup_bin_directory(d)

            self.assertFalse(os.path.exists(os.path.join(d, TAR_FILE)))
            for f in INPUT_FILES:
                self.assertFalse(os.path.exists(os.path.join(d, f + '.bin')))
Esempio n. 7
0
    def test_some_files_are_missing_check_il_is_true___error_is_raised(self, missing):
        with TemporaryDirectory() as d:
            tar_file_name = os.path.join(d, 'exposures.tar')

            with tarfile.open(tar_file_name, 'w', encoding='utf-8') as tar:
                for f in INPUT_FILES.values():
                    if f['name'] in missing:
                        continue

                    Path(os.path.join(d, '{}.bin'.format(f['name']))).touch()

                tar.add(d, arcname='/')

            with self.assertRaises(OasisException):
                check_binary_tar_file(tar_file_name, check_il=True)