def runTest(self): # ARRANGE # program_symbol_name = 'PROGRAM_SYMBOL' # ACT && ASSERT # integration_check.CHECKER__PARSE_FULL.check_multi( self, args.RunProgram( program_args.symbol_ref_command_elements( program_symbol_name)).as_arguments, ParseExpectation( source=asrt_source.is_at_end_of_line(1), symbol_references=asrt.matches_sequence([ is_reference_to_program(program_symbol_name), ]), ), model_constructor.arbitrary(self), [ validation_cases.validation_exe_case(validation_case) for validation_case in validation_cases.failing_validation_cases( program_symbol_name, 'TRANSFORMER_SYMBOL') ], )
def test_result_SHOULD_be_true_iff_exit_code_is_0(self): # ARRANGE # program_symbol_name = 'PROGRAM_THAT_EXECUTES_PY_FILE' exit_code_symbol_name = 'EXIT_CODE_SYMBOL' # ACT && ASSERT # integration_check.CHECKER__PARSE_FULL.check_multi( self, args.RunProgram( program_args.symbol_ref_command_elements( program_symbol_name, arguments=[ symbol_reference_syntax_for_name(exit_code_symbol_name) ], )).as_arguments, ParseExpectation( source=asrt_source.is_at_end_of_line(1), symbol_references=asrt.matches_sequence([ is_reference_to_program(program_symbol_name), is_reference_to__w_str_rendering(exit_code_symbol_name), ]), ), integration_check.ARBITRARY_MODEL, test_cases.exit_code_exe_cases( program_symbol_name, exit_code_symbol_name, ), )
def _check( put: unittest.TestCase, arg_pos_option: PathArgumentPositionArgument, command_line_arguments_cases: List[List[str]], expected_arg_list: Callable[[List[str], str], List[str]], ): # ARRANGE # program_symbol_name = 'PROGRAM_THAT_EXECUTES_PY_FILE' command_line_arg_list_symbol_name = 'COMMAND_LINE_ARGUMENTS_LIST' model_file_path = 'the-file-to-match' # ACT && ASSERT # integration_check.CHECKER__PARSE_FULL.check_multi__w_source_variants_for_full_line_parser( put, args.RunProgram( program_args.symbol_ref_command_elements( program_symbol_name, arguments=[symbol_reference_syntax_for_name(command_line_arg_list_symbol_name)], ), arg_pos_option, ).as_arguments, input_=integration_check.constant_relative_file_name(model_file_path), symbol_references=asrt.matches_sequence([ is_reference_to_program(program_symbol_name), is_reference_to__w_str_rendering(command_line_arg_list_symbol_name), ]), execution=[ test_cases.argument_list_exe_case( command_line_arguments, expected_arg_list(command_line_arguments, model_file_path), program_symbol_name, command_line_arg_list_symbol_name) for command_line_arguments in command_line_arguments_cases ], )
def runTest(self): # ARRANGE # program_symbol_name = 'PROGRAM_THAT_EXECUTES_PY_FILE' environment_cases = [ { '1': 'one', }, { '1': 'one', '2': 'two', }, ] # ACT && ASSERT # integration_check.CHECKER__PARSE_FULL.check_multi( self, args.RunProgram( program_args.symbol_ref_command_elements( program_symbol_name, arguments=[], ) ).as_arguments, ParseExpectation( source=asrt_source.is_at_end_of_line(1), symbol_references=asrt.matches_singleton_sequence( is_reference_to_program(program_symbol_name) ), ), integration_check.ARBITRARY_MODEL, [ test_cases.environment_exe_case(environment_case, program_symbol_name) for environment_case in environment_cases ], )
def runTest(self): # ARRANGE # program_symbol_name = 'PROGRAM_THAT_EXECUTES_PY_FILE' command_line_arg_list_symbol_name = 'COMMAND_LINE_ARGUMENTS_LIST' command_line_arguments_cases = [ [], ['one'], ['one', 'two'], ] # ACT && ASSERT # integration_check.CHECKER__PARSE_FULL.check_multi__w_source_variants_for_full_line_parser( self, args.RunProgram( program_args.symbol_ref_command_elements( program_symbol_name, arguments=[ symbol_reference_syntax_for_name( command_line_arg_list_symbol_name) ], )).as_arguments, model_constructor.arbitrary(self), symbol_references=asrt.matches_sequence([ is_reference_to_program(program_symbol_name), is_reference_to__w_str_rendering( command_line_arg_list_symbol_name), ]), execution=[ test_cases.argument_list_exe_case( command_line_arguments, command_line_arguments, program_symbol_name, command_line_arg_list_symbol_name) for command_line_arguments in command_line_arguments_cases ], )
def reference_assertion(self, symbol_name: str) -> Assertion[SymbolReference]: return is_reference_to_program(symbol_name)
def run_test(self): # ARRANGE # arguments_of_referenced_sdv_symbol = ListConstantSymbolContext( 'ARGUMENT_OF_SDV_SYMBOL', ['argument of sdv 1', 'argument of sdv 2'], ) referenced_system_program_name = 'the-referenced-system-program' referenced_program_arguments = arguments_of_referenced_sdv_symbol.constant_list referenced_system_program_sdv = program_sdvs.system_program( string_sdvs.str_constant(referenced_system_program_name), ArgumentsSdv.new_without_validation( list_sdvs.from_elements([ list_sdvs.symbol_element( SymbolReference( arguments_of_referenced_sdv_symbol.name, ValueTypeRestriction.of_single(ValueType.LIST))) ]))) program_symbol = ProgramSymbolContext.of_sdv( 'PROGRAM_SYMBOL', referenced_system_program_sdv) string_argument_symbol = StringConstantSymbolContext( 'STRING_ARGUMENT_SYMBOL', 'string argument') list_argument_symbol = ListConstantSymbolContext( 'LIST_ARGUMENT_SYMBOL', ['list arg value 1', 'list arg value 2']) symbols = SymbolContext.symbol_table_of_contexts([ program_symbol, arguments_of_referenced_sdv_symbol, string_argument_symbol, list_argument_symbol ]) cases = [ SymbolReferencesCase( 'just program reference symbol', self.source_to_parse(program_symbol.name, ()), references_expectation=asrt.matches_sequence([ references.is_reference_to_program(program_symbol.name), ]), expected_additional_arguments=[], ), SymbolReferencesCase( 'arguments that are references to string and list symbols', self.source_to_parse(program_symbol.name, [ ArgumentOfSymbolReferenceAbsStx( string_argument_symbol.name), ArgumentOfSymbolReferenceAbsStx(list_argument_symbol.name) ]), references_expectation=asrt.matches_sequence([ references.is_reference_to_program(program_symbol.name), string_argument_symbol. reference_assertion__w_str_rendering, list_argument_symbol.reference_assertion__w_str_rendering, ]), expected_additional_arguments=( [string_argument_symbol.str_value] + list_argument_symbol.constant_list), ), ] for case in cases: def expected_program( env: AssertionResolvingEnvironment) -> Assertion[Program]: return asrt_pgm_val.matches_program( command=asrt_command.equals_system_program_command( program=referenced_system_program_name, arguments=referenced_program_arguments + case.expected_additional_arguments, ), stdin=asrt_pgm_val.is_no_stdin(), transformer=asrt_pgm_val.is_no_transformation(), ) expectation = MultiSourceExpectation( symbol_references=case.references_expectation, primitive=expected_program, ) with self.put.subTest(case=case.name): # ACT & ASSERT # self.integration_checker( ).check__abs_stx__layouts__source_variants__wo_input( self.put, equivalent_source_variants__for_consume_until_end_of_last_line__s__nsc, case.source, arrangement_wo_tcds(symbols=symbols, ), expectation, )