Beispiel #1
0
 def __init__(self, files: Sequence[FileSpecificationDdv]):
     self._files = files
     validators = [
         file.validator()
         for file in files
     ]
     self._validator = ddv_validators.all_of(validators)
Beispiel #2
0
 def __init__(
     self,
     operands: Sequence[MatcherDdv[MODEL]],
     model_freezer: Callable[[MODEL], MODEL],
 ):
     self._operands = operands
     self._model_freezer = model_freezer
     self._validator = ddv_validators.all_of(
         [matcher.validator for matcher in operands])
Beispiel #3
0
 def __init__(self,
              name: str,
              range_expr_handlers: Sequence[_RangeExprHandler],
              ):
     self._name = name
     self._range_expr_handlers = range_expr_handlers
     self._validator = ddv_validators.all_of([
         reh.validator
         for reh in range_expr_handlers
     ])
Beispiel #4
0
 def validator(self) -> DdvValidator:
     return (
         self._regex.validator()
         if self._lines_selector is None
         else
         ddv_validators.all_of([
             self._lines_selector.validator,
             self._regex.validator(),
         ])
     )
Beispiel #5
0
    def _assert_passes_validation(
            self, actual: PathSdv,
            environment: PathResolvingEnvironmentPreOrPostSds):
        path_as_exe_file_cmd = command_sdvs.for_executable_file(actual)
        actual_validator = ddv_validators.all_of(
            path_as_exe_file_cmd.resolve(environment.symbols).validators)

        assertion = ddv_assertions.DdvValidationAssertion.of_expectation(
            validation.Expectation.passes_all(), environment.tcds)
        assertion.apply_with_message(self, actual_validator, 'validation')
Beispiel #6
0
 def __init__(self,
              name: str,
              maker: FileMakerDdv,
              ):
     self.name = name
     self.maker = maker
     self._validator = ddv_validators.all_of([
         _IsValidPosixPath(name),
         self.maker.validator,
     ])
Beispiel #7
0
 def __init__(
     self,
     min_depth: Optional[IntegerDdv],
     max_depth: Optional[IntegerDdv],
 ):
     self._min_depth = min_depth
     self._max_depth = max_depth
     self._validator = ddv_validators.all_of([
         int_ddv.validator() for int_ddv in [min_depth, max_depth]
         if int_ddv is not None
     ])
Beispiel #8
0
    def validator_validator_of_files(self) -> DdvValidator:
        validators = []

        for file_name, mb_matcher in self._files:
            validators.append(
                _IsRelativePosixPath(
                    file_name.value_when_no_dir_dependencies()))
            if mb_matcher is not None:
                validators.append(mb_matcher.validator)

        return ddv_validators.all_of(validators)
Beispiel #9
0
 def __init__(
     self,
     names: NamesSetup,
     model_constructor: FullDepsWithDetailsDescriptionDdv[
         ModelConstructor[CONTENTS_MATCHER_MODEL]],
     contents_matcher: MatcherDdv[CONTENTS_MATCHER_MODEL],
 ):
     self._names = names
     self._model_constructor = model_constructor
     self._contents_matcher = contents_matcher
     self._validators = ddv_validators.all_of(
         (model_constructor.validator, contents_matcher.validator))
Beispiel #10
0
 def __init__(self,
              matcher: MatcherDdv[PROP_TYPE],
              property_getter: PropertyGetterDdv[MODEL, PROP_TYPE],
              describer: PropertyMatcherDescriber,
              get_int_interval_of_prop_matcher:
              Optional[Callable[[MatcherWTrace[PROP_TYPE]], IntIntervalWInversion]] = None,
              ):
     self._matcher = matcher
     self._property_getter = property_getter
     self._describer = describer
     self._get_int_interval_of_prop_matcher = get_int_interval_of_prop_matcher
     self._validator = ddv_validators.all_of([
         self._matcher.validator,
         self._property_getter.validator,
     ])
Beispiel #11
0
    def _assert_does_not_pass_validation(
            self, actual: PathSdv,
            environment: PathResolvingEnvironmentPreOrPostSds):
        path_as_exe_file_cmd = command_sdvs.for_executable_file(actual)
        actual_validator = ddv_validators.all_of(
            path_as_exe_file_cmd.resolve(environment.symbols).validators)

        passes_pre_sds = not self.configuration.exists_pre_sds
        passes_post_sds = not passes_pre_sds
        expectation = validation.Expectation(
            passes_pre_sds=passes_pre_sds,
            passes_post_sds=passes_post_sds,
        )

        assertion = ddv_assertions.DdvValidationAssertion.of_expectation(
            expectation, environment.tcds)
        assertion.apply_with_message(self, actual_validator, 'validation')
Beispiel #12
0
 def _check(self, arguments_str: str,
            expected_source_after_parse: Assertion[ParseSource],
            expectation_on_exe_file: ExpectationOnExeFile,
            validator_expectation: validation.Expectation):
     # ARRANGE #
     source = ParseSource(arguments_str)
     # ACT #
     exe_file = sut.parser().parse(source)
     # ASSERT #
     utils.check_exe_file(self, expectation_on_exe_file, exe_file)
     expected_source_after_parse.apply_with_message(self, source,
                                                    'parse source')
     exe_file_command = command_sdvs.for_executable_file(exe_file)
     with tcds_with_act_as_curr_dir() as environment:
         actual_validator = ddv_validators.all_of(
             exe_file_command.resolve(environment.symbols).validators)
         assertion = ddv_assertions.DdvValidationAssertion.of_expectation(
             validator_expectation, environment.tcds)
         assertion.apply_with_message(self, actual_validator, 'validation')
Beispiel #13
0
def check(put: unittest.TestCase, instruction_argument_string: str,
          arrangement: Arrangement, expectation: Expectation):
    # ARRANGE #
    source = ParseSource(instruction_argument_string)
    # ACT #
    actual_exe_file = parse_executable_file_path.parser().parse(source)
    # ASSERT #
    exe_file_as_command = command_sdvs.for_executable_file(actual_exe_file)

    expectation.source.apply_with_message(put, source, 'parse source')
    check_exe_file(put, expectation.expectation_on_exe_file, actual_exe_file)
    with tcds_with_act_as_curr_dir(
            tcds_contents=arrangement.tcds_populator) as environment:
        os.mkdir('act-cwd')
        os.chdir('act-cwd')
        actual_validator = ddv_validators.all_of(
            exe_file_as_command.resolve(environment.symbols).validators)

        assertion = ddv_assertions.DdvValidationAssertion.of_expectation(
            expectation.validation_result, environment.tcds)
        assertion.apply_with_message(put, actual_validator, 'validation')
Beispiel #14
0
 def validator(self) -> DdvValidator:
     return ddv_validators.all_of(self._validators)
 def _ddvs(self, symbols: SymbolTable) -> Tuple[ModelGetterDdv[MODEL], MatcherDdv[MODEL], DdvValidator]:
     model_getter = self._model_getter.resolve(symbols)
     matcher = self._matcher.resolve(symbols)
     return (model_getter,
             matcher,
             ddv_validators.all_of([model_getter.validator, matcher.validator]))
Beispiel #16
0
 def get_validator(symbols: SymbolTable) -> DdvValidator:
     return ddv_validators.all_of(
         executable_object.program.resolve(symbols).validators)
Beispiel #17
0
 def validator(self) -> DdvValidator:
     return ddv_validators.all_of(
         [self._transformed.validator, self._transformer.validator])
Beispiel #18
0
 def get_ddv_validator(symbols: SymbolTable) -> DdvValidator:
     return ddv_validators.all_of([
         model_constructor.resolve(symbols).validator,
         files_matcher.resolve(symbols).validator,
     ])
Beispiel #19
0
 def get_interpreter_and_args_validator(
         symbols: SymbolTable) -> DdvValidator:
     return ddv_validators.all_of(
         tuple(self._interpreter.resolve(symbols).validators) +
         tuple(info.arguments.resolve(symbols).validators))