Beispiel #1
0
 def test_fail_due_to_unexpected_resolved_value(self):
     # ARRANGE #
     string_sdv = _StringSdvTestImpl(resolve_constant(STRING_DDV))
     assertion = sut.matches_sdv(asrt.anything_goes(), asrt.anything_goes(),
                                 asrt.not_(asrt.is_(STRING_DDV)))
     # ACT & ASSERT #
     test_of_test_resources_util.assert_that_assertion_fails(
         assertion, string_sdv)
def matches_sdv_of_path(
        references: Assertion[Sequence[SymbolReference]],
        ddv: Assertion[PathDdv],
        custom: Assertion[PathSdv] = asrt.anything_goes(),
        symbols: Optional[SymbolTable] = None
) -> Assertion[SymbolDependentValue]:
    return matches_sdv(asrt.is_instance(PathSdv), references,
                       asrt.is_instance_with(PathDdv, ddv), custom,
                       symbol_table_from_none_or_value(symbols))
def matches_sdv_of_program(
        references: Assertion[Sequence[SymbolReference]],
        primitive_value: Callable[[TestCaseDs], Assertion[Program]],
        symbols: Optional[SymbolTable] = None
) -> Assertion[SymbolDependentValue]:
    return matches_sdv(
        asrt.is_instance(ProgramSdv), references,
        asrt.is_instance_with(
            ProgramDdv,
            asrt_logic.matches_logic_ddv(lambda tcds: asrt.is_instance_with(
                Program, primitive_value(tcds)))), asrt.anything_goes(),
        symbol_table_from_none_or_value(symbols))
def matches_sdv_of_string_transformer_constant(
        references: Assertion[
            Sequence[SymbolReference]] = asrt.anything_goes(),
        primitive_value: Assertion[StringTransformer] = asrt.anything_goes(),
        symbols: SymbolTable = None) -> Assertion[SymbolDependentValue]:
    return matches_sdv(
        asrt.is_instance(StringTransformerSdv), references,
        asrt.is_instance_with(
            StringTransformerDdv,
            asrt_logic.matches_logic_ddv(lambda tcds: asrt.is_instance_with(
                StringTransformer, primitive_value))), asrt.anything_goes(),
        symbol_table_from_none_or_value(symbols))
def matches_sdv_of_files_condition_constant(
        references: Assertion[
            Sequence[SymbolReference]] = asrt.anything_goes(),
        primitive_value: Assertion[FilesCondition] = asrt.anything_goes(),
        symbols: SymbolTable = None) -> Assertion[SymbolDependentValue]:
    return matches_sdv(
        asrt.is_instance(FilesConditionSdv), references,
        asrt.is_instance_with(
            FilesConditionDdv,
            asrt_logic.matches_logic_ddv(lambda tcds: asrt.is_instance_with(
                FilesCondition, primitive_value))), asrt.anything_goes(),
        symbol_table_from_none_or_value(symbols))
Beispiel #6
0
    def test_fail_due_to_unexpected_references(self):
        # ARRANGE #
        reference = data_references.reference_to__on_direct_and_indirect(
            'symbol_name')
        string_sdv_with_single_reference = _StringSdvTestImpl(
            explicit_references=[reference])

        assertion = sut.matches_sdv(asrt.anything_goes(),
                                    asrt.is_empty_sequence,
                                    asrt.anything_goes())
        # ACT & ASSERT #
        test_of_test_resources_util.assert_that_assertion_fails(
            assertion, string_sdv_with_single_reference)
def matches_matcher_sdv(
        primitive_value: Assertion[MatcherWTrace] = asrt.anything_goes(),
        references: Assertion[
            Sequence[SymbolReference]] = asrt.is_empty_sequence,
        symbols: SymbolTable = None,
        tcds: TestCaseDs = fake_tcds(),
) -> Assertion[SymbolDependentValue]:
    return matches_sdv(
        asrt.is_instance(MatcherSdv), references,
        asrt.is_instance_with(
            MatcherDdv,
            asrt_logic.matches_matcher_ddv(lambda tcds_: primitive_value,
                                           tcds)), asrt.anything_goes(),
        symbol_table_from_none_or_value(symbols))
Beispiel #8
0
 def test_success(self):
     # ARRANGE #
     path_symbol = PathDdvSymbolContext(
         'symbol_name', path_ddvs.of_rel_option(RelOptionType.REL_ACT))
     reference = data_references.reference_to__on_direct_and_indirect(
         path_symbol.name)
     path_sdv = PathSdvTestImplWithConstantPathAndSymbolReferences(
         path_symbol.ddv, [reference])
     assertion = sut.matches_sdv(asrt.is_instance(PathSdv),
                                 asrt.len_equals(1),
                                 asrt.is_(path_symbol.ddv),
                                 asrt.is_(path_sdv),
                                 symbols=path_symbol.symbol_table)
     # ACT & ASSERT #
     assertion.apply_without_message(self, path_sdv)
Beispiel #9
0
 def sdv_assertion(
     self,
     tcds: TestCaseDs,
     arguments: Assertion[Sequence[str]],
     arguments_symbols: Sequence[SymbolContext] = (),
 ) -> Assertion[SymbolDependentValue]:
     expected_command = asrt_command.matches_command(
         driver=self.expected_command_driver(tcds), arguments=arguments)
     symbols = tuple(self.symbols) + tuple(arguments_symbols)
     return matches_sdv(
         asrt.is_instance(CommandSdv),
         symbols=SymbolContext.symbol_table_of_contexts(symbols),
         references=SymbolContext.references_assertion_of_contexts(symbols),
         resolved_value=asrt.is_instance_with(
             CommandDdv,
             matches_dir_dependent_value(lambda _: expected_command)),
     )
Beispiel #10
0
    def test_symbol_table_is_passed_to_resolve_method(self):
        # ARRANGE #
        symbol_name = 'symbol_name'
        symbol_value = 'the symbol value'
        string_sdv = _StringSdvTestImpl(
            resolve_string_via_symbol_table(symbol_name))

        symbol_table = StringConstantSymbolContext(symbol_name,
                                                   symbol_value).symbol_table
        is_expected_resolved_value = asrt.on_transformed(
            _resolve_ddv, asrt.equals(symbol_value))
        assertion = sut.matches_sdv(asrt.anything_goes(),
                                    asrt.anything_goes(),
                                    is_expected_resolved_value,
                                    symbols=symbol_table)
        # ACT & ASSERT #
        assertion.apply_without_message(self, string_sdv)
Beispiel #11
0
 def test_fail_due_to_unexpected_sdv_type(self):
     # ARRANGE #
     cases = [
         NameAndValue(
             'unexpected logic type',
             LineMatcherSymbolValueContext.of_primitive_constant(False).sdv,
         ),
         NameAndValue(
             'data type',
             StringSymbolValueContext.of_constant('value').sdv,
         ),
     ]
     assertion = sut.matches_sdv(asrt.is_instance(ProgramSdv),
                                 asrt.anything_goes(), asrt.anything_goes())
     # ACT & ASSERT #
     for case in cases:
         with self.subTest(case.name):
             test_of_test_resources_util.assert_that_assertion_fails(
                 assertion, case.value)