def _test_case(self) -> test_case_doc.TestCase: return full_test_case_with_instructions( [ configuration_phase_instruction_that( main_initial_action= _ConfigurationPhaseActionThatSetsHdsCaseDirToParent()), configuration_phase_instruction_that( main_initial_action= _ConfigurationPhaseActionThatSetsHdsActDirToParentParent()) ], [ setup_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars( self.recorder, phase_step.SETUP__VALIDATE_PRE_SDS).call, validate_post_setup_initial_action=_RecordEnvVars( self.recorder, phase_step.SETUP__VALIDATE_POST_SETUP).call, main_initial_action=_RecordEnvVars( self.recorder, phase_step.SETUP__MAIN).setup_main) ], [], [ before_assert_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars( self.recorder, phase_step.BEFORE_ASSERT__VALIDATE_PRE_SDS).call, validate_post_setup_initial_action=_RecordEnvVars( self.recorder, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP).call, main_initial_action=_RecordEnvVars( self.recorder, phase_step.BEFORE_ASSERT__MAIN).non_setup_main) ], [ assert_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars( self.recorder, phase_step.ASSERT__VALIDATE_PRE_SDS).call, validate_post_setup_initial_action=_RecordEnvVars( self.recorder, phase_step.ASSERT__VALIDATE_POST_SETUP).call, main_initial_action=_RecordEnvVars( self.recorder, phase_step.ASSERT__MAIN).non_setup_main) ], [ cleanup_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars( self.recorder, phase_step.CLEANUP__VALIDATE_PRE_SDS).call, main_initial_action=_RecordEnvVars( self.recorder, phase_step.CLEANUP__MAIN).non_setup_main) ], )
def _test_case(self) -> test_case_doc.TestCase: return full_test_case_with_instructions( [configuration_phase_instruction_that( main_initial_action=_RecordCurrDir(self.recorder, phase_step.CONFIGURATION__MAIN))], [setup_phase_instruction_that( validate_post_setup_initial_action=_RecordCurrDir(self.recorder, phase_step.SETUP__VALIDATE_POST_SETUP), main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.SETUP__MAIN))], [act_phase_instruction_with_source(LineSequence(1, ('not used',)))], [before_assert_phase_instruction_that( validate_post_setup_initial_action=_RecordCurrDir(self.recorder, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP), main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.BEFORE_ASSERT__MAIN))], [assert_phase_instruction_that( validate_post_setup_initial_action=_RecordCurrDir(self.recorder, phase_step.ASSERT__VALIDATE_POST_SETUP), main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.ASSERT__MAIN))], [cleanup_phase_instruction_that( main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.CLEANUP__MAIN))], )
def _test_case(self) -> test_case_doc.TestCase: return full_test_case_with_instructions( [configuration_phase_instruction_that( main_initial_action=_RecordCurrDir(self.recorder, phase_step.CONFIGURATION__MAIN).call)], [setup_phase_instruction_that( validate_post_setup_initial_action=_RecordCurrDir(self.recorder, phase_step.SETUP__VALIDATE_POST_SETUP), main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.SETUP__MAIN))], [act_phase_instruction_with_source(LineSequence(1, ('not used',)))], [before_assert_phase_instruction_that( validate_post_setup_initial_action=_RecordCurrDir(self.recorder, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP), main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.BEFORE_ASSERT__MAIN))], [assert_phase_instruction_that( validate_post_setup_initial_action=_RecordCurrDir(self.recorder, phase_step.ASSERT__VALIDATE_POST_SETUP), main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.ASSERT__MAIN))], [cleanup_phase_instruction_that( main_initial_action=_RecordCurrDirThenMakeDirAndChangeToIt(self.recorder, phase_step.CLEANUP__MAIN))], )
def _test_case(self) -> test_case_doc.TestCase: return full_test_case_with_instructions( [ configuration_phase_instruction_that( main_initial_action=_ConfigurationPhaseActionThatSetsHomeCaseDirToParent()), configuration_phase_instruction_that( main_initial_action=_ConfigurationPhaseActionThatSetsHomeActDirToParentParent()) ], [setup_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars(self.recorder, phase_step.SETUP__VALIDATE_PRE_SDS), validate_post_setup_initial_action=_RecordEnvVars(self.recorder, phase_step.SETUP__VALIDATE_POST_SETUP), main_initial_action=_RecordEnvVars(self.recorder, phase_step.SETUP__MAIN))], [], [before_assert_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars(self.recorder, phase_step.BEFORE_ASSERT__VALIDATE_PRE_SDS), validate_post_setup_initial_action=_RecordEnvVars(self.recorder, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP), main_initial_action=_RecordEnvVars(self.recorder, phase_step.BEFORE_ASSERT__MAIN))], [assert_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars(self.recorder, phase_step.ASSERT__VALIDATE_PRE_SDS), validate_post_setup_initial_action=_RecordEnvVars(self.recorder, phase_step.ASSERT__VALIDATE_POST_SETUP), main_initial_action=_RecordEnvVars(self.recorder, phase_step.ASSERT__MAIN))], [cleanup_phase_instruction_that( validate_pre_sds_initial_action=_RecordEnvVars(self.recorder, phase_step.CLEANUP__VALIDATE_PRE_SDS), main_initial_action=_RecordEnvVars(self.recorder, phase_step.CLEANUP__MAIN))], )
def instruction_set() -> InstructionsSetup: return InstructionsSetup( config_instruction_set=dict( [instruction_item('conf_instruction', instr.configuration_phase_instruction_that())]), setup_instruction_set=dict( [instruction_item('setup_instruction', instr.setup_phase_instruction_that())]), before_assert_instruction_set=dict( [instruction_item('before_assert_instruction', instr.before_assert_phase_instruction_that())]), assert_instruction_set=dict( [instruction_item('assert_instruction', instr.assert_phase_instruction_that())]), cleanup_instruction_set=dict( [instruction_item('cleanup_instruction', instr.cleanup_phase_instruction_that())]), )
def test_implementation_error_in_configuration_phase(self): test_case = test_case_with_two_instructions_in_each_phase() \ .add(phase_identifier.CONFIGURATION, test.configuration_phase_instruction_that( main=do_raise(test.ImplementationErrorTestException()))) self._check( Arrangement(test_case), Expectation( asrt_result.matches2( FullExeResultStatus.IMPLEMENTATION_ERROR, asrt_result.has_no_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForInstructionFailure.new_with_exception( phase_step.CONFIGURATION__MAIN, test_case.the_extra(phase_identifier.CONFIGURATION)[0].source, test.ImplementationErrorTestException), ), [phase_step.CONFIGURATION__MAIN], ))
def test_hard_error_in_configuration_phase(self): test_case_generator = test_case_with_two_instructions_in_each_phase() \ .add(phase_identifier.CONFIGURATION, test.configuration_phase_instruction_that(do_return(sh.new_sh_hard_error('hard error msg')))) self._check( Arrangement(test_case_generator), Expectation( asrt_result.matches2( FullExeResultStatus.HARD_ERROR, asrt_result.has_no_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForInstructionFailure.new_with_message( phase_step.CONFIGURATION__MAIN, test_case_generator.the_extra(phase_identifier.CONFIGURATION)[ 0].source, 'hard error msg') ), [phase_step.CONFIGURATION__MAIN], ))
def test_execution_mode_skipped_but_failing_instruction_in_configuration_phase_after_setting_execution_mode(self): test_case = test_case_with_two_instructions_in_each_phase() \ .add(phase_identifier.CONFIGURATION, test.ConfigurationPhaseInstructionThatSetsExecutionMode( TestCaseStatus.SKIP)) \ .add(phase_identifier.CONFIGURATION, test.configuration_phase_instruction_that(do_return(sh.new_sh_hard_error('hard error msg')))) self._check( Arrangement(test_case), Expectation( asrt_result.matches2( FullExeResultStatus.HARD_ERROR, asrt_result.has_no_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForInstructionFailure.new_with_message( phase_step.CONFIGURATION__MAIN, test_case.the_extra(phase_identifier.CONFIGURATION)[1].source, 'hard error msg')), [phase_step.CONFIGURATION__MAIN], ))
def test_execution_mode_skipped_but_failing_instruction_in_configuration_phase_after_setting_execution_mode(self): test_case = test_case_with_two_instructions_in_each_phase() \ .add(phase_identifier.CONFIGURATION, test.ConfigurationPhaseInstructionThatSetsExecutionMode( TestCaseStatus.SKIP)) \ .add(phase_identifier.CONFIGURATION, test.configuration_phase_instruction_that(do_return(svh.new_svh_hard_error__str('hard error msg')))) self._check( Arrangement(test_case), Expectation( asrt_result.matches2( FullExeResultStatus.HARD_ERROR, asrt_result.has_no_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForInstructionFailure.new_with_message( phase_step.CONFIGURATION__MAIN, test_case.the_extra(phase_identifier.CONFIGURATION)[1].source, 'hard error msg')), [phase_step.CONFIGURATION__MAIN], ))
def conf_instr_setup(self) -> SingleInstructionSetup: return instr_setup(instr.configuration_phase_instruction_that( main_initial_action=do_raise(ImplementationError()) ))
def conf_instr_setup(self) -> SingleInstructionSetup: return instr_setup(instr.configuration_phase_instruction_that())
def conf_instr_setup(self) -> SingleInstructionSetup: return instr_setup(instr.configuration_phase_instruction_that( main_initial_action=append_section_name_action(self.recording_output, phase_identifier.CONFIGURATION)) )
def new_configuration_instruction(self, value) -> ConfigurationPhaseInstruction: return configuration_phase_instruction_that( main=self._do_record_and_return_svh(value))
def parse(self, fs_location_info: FileSystemLocationInfo, source: ParseSource) -> model.Instruction: source.consume_current_line() self._assert_root_source_file_location_corresponds_to(fs_location_info) return configuration_phase_instruction_that()
def parse(self, fs_location_info: FileSystemLocationInfo, source: ParseSource) -> model.Instruction: source.consume_current_line() self._assert_root_source_file_location_corresponds_to(fs_location_info) return configuration_phase_instruction_that()
def conf_instr_setup(self) -> SingleInstructionSetup: return instr_setup( instr.configuration_phase_instruction_that( main_initial_action=append_section_name_action( self.recording_output, phase_identifier.CONFIGURATION)))
single_line_source def suite() -> unittest.TestSuite: return unittest.makeSuite(TestCases) class TestCases(instruction_check.TestCaseBase): def test_successful_flow(self): self._check(ParserThatGives(_SUCCESSFUL_INSTRUCTION), single_line_source(), Arrangement(), Expectation()) def test_fail_due_to_unexpected_result_from_main(self): with self.assertRaises(test_misc.TestError): self._check(ParserThatGives(_SUCCESSFUL_INSTRUCTION), single_line_source(), Arrangement(), Expectation(main_result=test_misc.raises_test_error())) def test_fail_due_to_fail_of_side_effects_on_configuration(self): with self.assertRaises(test_misc.TestError): self._check( ParserThatGives(_SUCCESSFUL_INSTRUCTION), single_line_source(), Arrangement(), Expectation(configuration=test_misc.raises_test_error())) _SUCCESSFUL_INSTRUCTION = configuration_phase_instruction_that() if __name__ == '__main__': unittest.TextTestRunner().run(suite())
def conf_instr_setup(self) -> SingleInstructionSetup: return instr_setup( instr.configuration_phase_instruction_that( main_initial_action=do_raise(ImplementationError())))
def conf_instr_setup(self) -> SingleInstructionSetup: return instr_setup(instr.configuration_phase_instruction_that())
def mk_instruction_with_main_action(self, main_action: Callable) -> Instruction: return configuration_phase_instruction_that(main_initial_action=main_action)
class TestCases(instruction_check.TestCaseBase): def test_successful_flow(self): self._check( ParserThatGives(_SUCCESSFUL_INSTRUCTION), single_line_source(), Arrangement(), Expectation()) def test_fail_due_to_unexpected_result_from_main(self): with self.assertRaises(test_misc.TestError): self._check( ParserThatGives(_SUCCESSFUL_INSTRUCTION), single_line_source(), Arrangement(), Expectation(main_result=test_misc.raises_test_error())) def test_fail_due_to_fail_of_side_effects_on_configuration(self): with self.assertRaises(test_misc.TestError): self._check( ParserThatGives(_SUCCESSFUL_INSTRUCTION), single_line_source(), Arrangement(), Expectation(configuration=test_misc.raises_test_error())) _SUCCESSFUL_INSTRUCTION = configuration_phase_instruction_that() if __name__ == '__main__': unittest.TextTestRunner().run(suite())
def new_configuration_instruction(self, value) -> ConfigurationPhaseInstruction: return configuration_phase_instruction_that(main=self._do_record_and_return_sh(value))
def _parse(self, rest_of_line: str) -> model.Instruction: return configuration_phase_instruction_that(main=do_return( svh.new_svh_hard_error__str('unconditional hard error')))