def runTest(self): # ARRANGE # symbol_in_program_source = NameAndValue('SYMBOL_IN_PROGRAM_SOURCE', data_restrictions_assertions.is__w_str_rendering()) symbol_in_matcher = NameAndValue('SYMBOL_IN_MATCHER', ss_references.IS_STRING_SOURCE_OR_STRING_REFERENCE_RESTRICTION) symbol_in_transformer_of_program = NameAndValue('SYMBOL_IN_TRANSFORMER_OF_PROGRAM', is_reference_restrictions__value_type( [ValueType.STRING_TRANSFORMER])) symbol_in_transformer_of_instruction = NameAndValue('SYMBOL_IN_TRANSFORMER_OF_INSTRUCTION', is_reference_restrictions__value_type( [ValueType.STRING_TRANSFORMER])) program_with_ref_to_symbols = pgm_args.program( pgm_args.interpret_py_source_line( self.configuration.py_source_for_print( symbol_reference_syntax_for_name(symbol_in_program_source.name))), transformation=symbol_in_transformer_of_program.name ) matcher_with_ref_to_symbol = matcher_arguments.equals_matcher(SymbolReferenceArgument(symbol_in_matcher.name)) arguments = po_ab.from_program(program_with_ref_to_symbols, matcher_with_ref_to_symbol, transformation=symbol_in_transformer_of_instruction.name) symbol_usages_assertion = asrt.matches_sequence([ matches_reference(symbol_in_program_source), matches_reference(symbol_in_transformer_of_program), matches_reference(symbol_in_transformer_of_instruction), matches_reference(symbol_in_matcher), ]) source = arguments.as_remaining_source # ACT # actual = self.configuration.parser().parse(ARBITRARY_FS_LOCATION_INFO, source) actual_symbol_usages = actual.symbol_usages() # ASSERT # symbol_usages_assertion.apply_without_message(self, actual_symbol_usages)
def test_fail_WHEN_restriction_is_of_other_type__multi(self): # ARRANGE # assertion_to_check = sut.is_reference_restrictions__value_type( [ValueType.PATH, ValueType.PROGRAM]) restriction = reference_restrictions.is_string__all_indirect_refs_are_strings( ) # ACT & ASSERT # assert_that_assertion_fails(assertion_to_check, restriction)
def test_succeed__multi(self): # ARRANGE # expected_types = [ValueType.FILE_MATCHER, ValueType.STRING] assertion_to_check = sut.is_reference_restrictions__value_type( expected_types) restriction = ValueTypeRestriction(expected_types) # ACT & ASSERT # assertion_to_check.apply_without_message(self, restriction)
from exactly_lib.symbol.sdv_structure import SymbolUsage, SymbolReference from exactly_lib.symbol.value_type import ValueType from exactly_lib_test.symbol.test_resources import symbol_usage_assertions as asrt_sym_usage from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt from exactly_lib_test.test_resources.value_assertions.value_assertion import Assertion from exactly_lib_test.type_val_deps.test_resources.any_.restrictions_assertions import \ is_reference_restrictions__value_type IS_FILES_CONDITION_REFERENCE_RESTRICTION = is_reference_restrictions__value_type( (ValueType.FILES_CONDITION, )) def is_reference_to_files_condition__usage( symbol_name: str) -> Assertion[SymbolUsage]: return asrt_sym_usage.matches_reference( asrt.equals(symbol_name), IS_FILES_CONDITION_REFERENCE_RESTRICTION) def is_reference_to_files_condition( symbol_name: str) -> Assertion[SymbolReference]: return asrt.is_instance_with( SymbolReference, asrt_sym_usage.matches_reference( asrt.equals(symbol_name), IS_FILES_CONDITION_REFERENCE_RESTRICTION))
from exactly_lib.symbol.sdv_structure import SymbolUsage, SymbolReference from exactly_lib.symbol.value_type import ValueType from exactly_lib_test.symbol.test_resources import symbol_usage_assertions as asrt_sym_usage from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt from exactly_lib_test.test_resources.value_assertions.value_assertion import Assertion from exactly_lib_test.type_val_deps.test_resources.any_.restrictions_assertions import \ is_reference_restrictions__value_type IS_STRING_TRANSFORMER_REFERENCE_RESTRICTION = is_reference_restrictions__value_type((ValueType.STRING_TRANSFORMER,)) def is_reference_to_string_transformer__usage(name_of_transformer: str) -> Assertion[SymbolUsage]: return asrt_sym_usage.matches_reference(asrt.equals(name_of_transformer), IS_STRING_TRANSFORMER_REFERENCE_RESTRICTION) def is_reference_to_string_transformer(name_of_transformer: str) -> Assertion[SymbolReference]: return asrt.is_instance_with(SymbolReference, asrt_sym_usage.matches_reference(asrt.equals(name_of_transformer), IS_STRING_TRANSFORMER_REFERENCE_RESTRICTION) )
from exactly_lib.symbol.sdv_structure import SymbolReference from exactly_lib.symbol.value_type import ValueType from exactly_lib_test.symbol.test_resources import symbol_reference_assertions as asrt_sym_ref from exactly_lib_test.test_resources.value_assertions.value_assertion import Assertion from exactly_lib_test.type_val_deps.test_resources.any_.restrictions_assertions import \ is_reference_restrictions__value_type from exactly_lib_test.type_val_deps.test_resources.w_str_rend import data_restrictions_assertions as asrt_w_str_rend IS_STRING_SOURCE_OR_STRING_REFERENCE_RESTRICTION = is_reference_restrictions__value_type( (ValueType.STRING_SOURCE, ValueType.STRING)) IS_STRING_REFERENCE_RESTRICTION = asrt_w_str_rend.is__w_str_rendering() def is_reference_to__string_source_or_string( symbol_name: str) -> Assertion[SymbolReference]: return asrt_sym_ref.matches_reference_2( symbol_name, IS_STRING_SOURCE_OR_STRING_REFERENCE_RESTRICTION, ) def is_reference_to__string(symbol_name: str) -> Assertion[SymbolReference]: return asrt_sym_ref.matches_reference_2( symbol_name, IS_STRING_REFERENCE_RESTRICTION, )
from exactly_lib.symbol.sdv_structure import SymbolUsage, SymbolReference from exactly_lib.symbol.value_type import ValueType from exactly_lib_test.symbol.test_resources import symbol_usage_assertions as asrt_sym_usage from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt from exactly_lib_test.test_resources.value_assertions.value_assertion import Assertion from exactly_lib_test.type_val_deps.test_resources.any_.restrictions_assertions import \ is_reference_restrictions__value_type IS_LINE_MATCHER_REFERENCE_RESTRICTION = is_reference_restrictions__value_type( (ValueType.LINE_MATCHER, )) def is_reference_to_line_matcher__usage( symbol_name: str) -> Assertion[SymbolUsage]: return asrt_sym_usage.matches_reference( asrt.equals(symbol_name), IS_LINE_MATCHER_REFERENCE_RESTRICTION) def is_reference_to_line_matcher( symbol_name: str) -> Assertion[SymbolReference]: return asrt.is_instance_with( SymbolReference, asrt_sym_usage.matches_reference( asrt.equals(symbol_name), IS_LINE_MATCHER_REFERENCE_RESTRICTION))
from exactly_lib.symbol.sdv_structure import SymbolUsage, SymbolReference from exactly_lib.symbol.value_type import ValueType from exactly_lib_test.symbol.test_resources import symbol_usage_assertions as asrt_sym_usage from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt from exactly_lib_test.test_resources.value_assertions.value_assertion import Assertion from exactly_lib_test.type_val_deps.test_resources.any_.restrictions_assertions import \ is_reference_restrictions__value_type IS_PROGRAM_REFERENCE_RESTRICTION = is_reference_restrictions__value_type( (ValueType.PROGRAM, )) def is_reference_to_program__usage(symbol_name: str) -> Assertion[SymbolUsage]: return asrt_sym_usage.matches_reference(asrt.equals(symbol_name), IS_PROGRAM_REFERENCE_RESTRICTION) def is_reference_to_program(symbol_name: str) -> Assertion[SymbolReference]: return asrt.is_instance_with( SymbolReference, asrt_sym_usage.matches_reference(asrt.equals(symbol_name), IS_PROGRAM_REFERENCE_RESTRICTION))