def test_il_is_true_gul_bin_files_are_present___exception_is_raised(self):
        with TemporaryDirectory() as d:
            for p in chain(GUL_INPUT_FILES.values(), IL_INPUT_FILES.values()):
                Path(os.path.join(d, p['name'] + '.csv')).touch()

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

            with self.assertRaises(OasisException):
                check_inputs_directory(d, True)
Example #2
0
    def test_il_is_true_all_input_files_are_present___no_exception_is_raised(self):
        with TemporaryDirectory() as d:
            for p in chain(GUL_INPUT_FILES.values(), IL_INPUT_FILES.values()):
                Path(os.path.join(d, p['name'] + '.csv')).touch()

            try:
                check_inputs_directory(d, True)
            except Exception as e:
                self.fail('Exception was raised {}: {}'.format(type(e), e))
Example #3
0
    def test_do_is_is_false_non_il_input_files_are_present___no_exception_is_raised(self):
        with TemporaryDirectory() as d:
            for input_file in GUL_INPUT_FILES.values():
                Path(os.path.join(d, input_file['name'] + '.csv')).touch()

            try:
                check_inputs_directory(d, False)
            except Exception as e:
                self.fail('Exception was raised {}: {}'.format(type(e), e))
Example #4
0
def standard_input_files(min_size=0):
    return lists(
        sampled_from([
            target['name'] for target in chain(GUL_INPUT_FILES.values(),
                                               OPTIONAL_INPUT_FILES.values())
        ]),
        min_size=min_size,
        unique=True,
    )
    def test_all_il_files_are_missing_check_il_is_false___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 GUL_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))
Example #6
0
class CheckBinTarFile(TestCase):
    def test_all_il_files_are_missing_check_il_is_false___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 GUL_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))

    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))

    @given(
        lists(sampled_from([
            f['name']
            for f in chain(GUL_INPUT_FILES.values(), IL_INPUT_FILES.values())
        ]),
              min_size=1,
              unique=True))
    @settings(deadline=None, suppress_health_check=[HealthCheck.too_slow])
    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)