Пример #1
0
 def test_hard_error(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(
             test_case,
             atc_execute=execute_action_that_returns_hard_error_with_message(
                 'error in execute')),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR, asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_message(
                     phase_step.ACT__EXECUTE, 'error in execute')),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE +
             PRE_SDS_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_EXE_INPUT,
                 phase_step.ACT__PREPARE,
                 phase_step.ACT__EXECUTE,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.ACT),
             ],
         ))
Пример #2
0
 def test_internal_error(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     atc_execute=execute_action_that_raises(
                         test.ImplementationErrorTestException())),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.INTERNAL_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_exception(
                     phase_step.ACT__EXECUTE,
                     test.ImplementationErrorTestException)),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE +
             PRE_SDS_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_EXE_INPUT,
                 phase_step.ACT__PREPARE,
                 phase_step.ACT__EXECUTE,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.ACT),
             ],
         ))
Пример #3
0
    def test_hard_error_exception(self):
        failure_message = 'HE exception in act/validate exe info'

        def validator_that_raises_hard_error() -> Optional[TextRenderer]:
            raise hard_error_ex(failure_message)

        test_case = _single_successful_instruction_in_each_phase()
        self._check(
            Arrangement(test_case),
            custom_act_execution_input_validator=
            validator_that_raises_hard_error,
            expectation=Expectation(
                asrt_result.matches2(
                    ExecutionFailureStatus.HARD_ERROR, asrt_result.has_sds(),
                    asrt_result.has_no_action_to_check_outcome(),
                    ExpectedFailureForPhaseFailure.new_with_message(
                        phase_step.ACT__VALIDATE_EXE_INPUT, failure_message)),
                [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE +
                PRE_SDS_VALIDATION_STEPS__ONCE + [
                    phase_step.SETUP__MAIN,
                    phase_step.SETUP__VALIDATE_POST_SETUP,
                    phase_step.ACT__VALIDATE_POST_SETUP,
                    phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                    phase_step.ASSERT__VALIDATE_POST_SETUP,
                    phase_step.ACT__VALIDATE_EXE_INPUT,
                    (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP),
                ],
            ))
Пример #4
0
    def test_internal_error(self):
        def validator_that_raises_exception() -> Optional[TextRenderer]:
            raise test.ImplementationErrorTestException()

        test_case = _single_successful_instruction_in_each_phase()
        self._check(Arrangement(test_case, ),
                    custom_act_execution_input_validator=
                    validator_that_raises_exception,
                    expectation=Expectation(
                        asrt_result.matches2(
                            ExecutionFailureStatus.INTERNAL_ERROR,
                            asrt_result.has_sds(),
                            asrt_result.has_no_action_to_check_outcome(),
                            ExpectedFailureForPhaseFailure.new_with_exception(
                                phase_step.ACT__VALIDATE_EXE_INPUT,
                                test.ImplementationErrorTestException),
                        ),
                        [phase_step.ACT__PARSE] +
                        SYMBOL_VALIDATION_STEPS__ONCE +
                        PRE_SDS_VALIDATION_STEPS__ONCE + [
                            phase_step.SETUP__MAIN,
                            phase_step.SETUP__VALIDATE_POST_SETUP,
                            phase_step.ACT__VALIDATE_POST_SETUP,
                            phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                            phase_step.ASSERT__VALIDATE_POST_SETUP,
                            phase_step.ACT__VALIDATE_EXE_INPUT,
                            (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP),
                        ],
                    ))
Пример #5
0
 def test_internal_error(self):
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(PartialPhase.SETUP,
              test.setup_phase_instruction_that(
                  main=do_raise(test.ImplementationErrorTestException())))
     self._check(
         Arrangement(test_case,
                     atc_execute=execute_action_that_returns_exit_code(5)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.INTERNAL_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_exception(
                     phase_step.SETUP__MAIN,
                     test_case.the_extra(PartialPhase.SETUP)[0].source,
                     test.ImplementationErrorTestException),
             ),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__TWICE +
             PRE_SDS_VALIDATION_STEPS__TWICE + [
                 phase_step.SETUP__MAIN,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP),
                 (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP),
             ],
         ))
 def test_symbol_that_does_not_meet_restriction_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     symbol_name = 'symbol_name'
     reference_to_string_symbol = data_references.reference_to__on_direct_and_indirect(
         symbol_name, value_restrictions.is_string())
     definition_of_path_symbol = arbitrary_path_symbol_context(
         symbol_name).definition
     symbol_usages = [
         definition_of_path_symbol,
         reference_to_string_symbol,
     ]
     self._check(
         Arrangement(test_case, atc_symbol_usages=do_return(symbol_usages)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.VALIDATION_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_step(
                     phase_step.ACT__VALIDATE_SYMBOLS),
             ),
             [
                 phase_step.ACT__PARSE,
                 phase_step.SETUP__VALIDATE_SYMBOLS,
                 phase_step.ACT__VALIDATE_SYMBOLS,
             ],
         ))
Пример #7
0
 def runTest(self):
     conf = self.configuration
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(conf.phase,
              conf.instruction_that_returns(svh.new_svh_validation_error__str('validation error message')))
     execute_test_case_with_recording(
         self, Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.VALIDATION_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     conf.step,
                     test_case.the_extra(conf.phase)[0].source,
                     'validation error message'),
             ),
             conf.expected_steps,
         ))
Пример #8
0
 def test_exception(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     atc_validate_pre_sds=validate_action_that_raises(
                         test.ImplementationErrorTestException())),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.INTERNAL_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_exception(
                     phase_step.ACT__VALIDATE_PRE_SDS,
                     test.ImplementationErrorTestException)),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__VALIDATE_PRE_SDS,
                 phase_step.ACT__VALIDATE_PRE_SDS,
             ],
         ))
Пример #9
0
 def runTest(self):
     conf = self.configuration
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(conf.phase,
              conf.instruction_that_raises(hard_error_ex('Error message from hard error exception')))
     execute_test_case_with_recording(
         self, Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     conf.step,
                     test_case.the_extra(conf.phase)[0].source,
                     'Error message from hard error exception'),
             ),
             conf.expected_steps,
         ))
Пример #10
0
 def runTest(self):
     conf = self.configuration
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(conf.phase,
              conf.instruction_that_raises(test.ImplementationErrorTestException()))
     execute_test_case_with_recording(
         self, Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.INTERNAL_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_exception(
                     conf.step,
                     test_case.the_extra(conf.phase)[0].source,
                     test.ImplementationErrorTestException),
             ),
             conf.expected_steps,
         ))
 def test_internal_error_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     atc_symbol_usages=do_raise(
                         test.ImplementationErrorTestException())),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.INTERNAL_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_exception(
                     phase_step.ACT__VALIDATE_SYMBOLS,
                     test.ImplementationErrorTestException)),
             [
                 phase_step.ACT__PARSE,
                 phase_step.SETUP__VALIDATE_SYMBOLS,
                 phase_step.ACT__VALIDATE_SYMBOLS,
             ],
         ))
Пример #12
0
 def test_hard_error_exception(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(
             test_case,
             atc_validate_pre_sds=validate_action_that_raises(
                 hard_error_ex('HE exception in act/validate-pre-sds'))),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_message(
                     phase_step.ACT__VALIDATE_PRE_SDS,
                     'HE exception in act/validate-pre-sds')),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__VALIDATE_PRE_SDS,
                 phase_step.ACT__VALIDATE_PRE_SDS,
             ],
         ))
Пример #13
0
 def test(self):
     for expected_exit_code in [0, 72]:
         with self.subTest(expected_exit_code=expected_exit_code):
             self._check(
                 Arrangement(
                     TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr(
                     ),
                     atc_execute=execute_action_that_returns_exit_code(
                         expected_exit_code)),
                 Expectation(
                     asrt_result.matches2(
                         None,
                         asrt_result.has_sds(),
                         asrt_result.
                         has_action_to_check_outcome_with_exit_code(
                             expected_exit_code),
                         ExpectedFailureForNoFailure(),
                     ),
                     [phase_step.ACT__PARSE] +
                     SYMBOL_VALIDATION_STEPS__TWICE +
                     PRE_SDS_VALIDATION_STEPS__TWICE + [
                         phase_step.SETUP__MAIN,
                         phase_step.SETUP__MAIN,
                         phase_step.SETUP__VALIDATE_POST_SETUP,
                         phase_step.SETUP__VALIDATE_POST_SETUP,
                         phase_step.ACT__VALIDATE_POST_SETUP,
                         phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                         phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                         phase_step.ASSERT__VALIDATE_POST_SETUP,
                         phase_step.ASSERT__VALIDATE_POST_SETUP,
                         phase_step.ACT__VALIDATE_EXE_INPUT,
                         phase_step.ACT__PREPARE,
                         phase_step.ACT__EXECUTE,
                         phase_step.BEFORE_ASSERT__MAIN,
                         phase_step.BEFORE_ASSERT__MAIN,
                         phase_step.ASSERT__MAIN,
                         phase_step.ASSERT__MAIN,
                         (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT),
                         (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT),
                     ],
                 ))
Пример #14
0
 def test_hard_error(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     atc_validate_post_setup=validate_action_that_returns(
                         svh.new_svh_hard_error__str(
                             'error in act/validate-post-setup'))),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR, asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_message(
                     phase_step.ACT__VALIDATE_POST_SETUP,
                     'error in act/validate-post-setup')),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE +
             PRE_SDS_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_POST_SETUP,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP),
             ],
         ))
Пример #15
0
 def test_hard_error_exception(self):
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(PartialPhase.CLEANUP,
              test.cleanup_phase_instruction_that(
                  main=do_raise(hard_error_ex('hard error exception msg from CLEANUP'))))
     self._check(
         Arrangement(test_case,
                     atc_execute=execute_action_that_returns_exit_code(3)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_action_to_check_outcome_with_exit_code(3),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     phase_step.CLEANUP__MAIN,
                     test_case.the_extra(PartialPhase.CLEANUP)[0].source,
                     'hard error exception msg from CLEANUP'),
             ),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__TWICE +
             PRE_SDS_VALIDATION_STEPS__TWICE + [
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_EXE_INPUT,
                 phase_step.ACT__PREPARE,
                 phase_step.ACT__EXECUTE,
                 phase_step.BEFORE_ASSERT__MAIN,
                 phase_step.BEFORE_ASSERT__MAIN,
                 phase_step.ASSERT__MAIN,
                 phase_step.ASSERT__MAIN,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT),
             ],
         ))
Пример #16
0
 def test_fail(self):
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(PartialPhase.ASSERT,
              test.assert_phase_instruction_that(
                  main=do_return(pfh.new_pfh_fail__str('fail msg from ASSERT'))))
     self._check(
         Arrangement(test_case,
                     atc_execute=execute_action_that_returns_exit_code(5)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.FAIL,
                 asrt_result.has_sds(),
                 asrt_result.has_action_to_check_outcome_with_exit_code(5),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     phase_step.ASSERT__MAIN,
                     test_case.the_extra(PartialPhase.ASSERT)[0].source,
                     'fail msg from ASSERT'),
             ),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__TWICE +
             PRE_SDS_VALIDATION_STEPS__TWICE + [
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_EXE_INPUT,
                 phase_step.ACT__PREPARE,
                 phase_step.ACT__EXECUTE,
                 phase_step.BEFORE_ASSERT__MAIN,
                 phase_step.BEFORE_ASSERT__MAIN,
                 phase_step.ASSERT__MAIN,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT),
                 (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT),
             ],
         ))
 def test_symbol_that_does_meet_restriction_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     symbol_name = 'symbol_name'
     reference_to_string_symbol = data_references.reference_to__on_direct_and_indirect(
         symbol_name, value_restrictions.is_string())
     definition_of_string_symbol = StringConstantSymbolContext(
         symbol_name).definition
     symbol_usages = [
         definition_of_string_symbol,
         reference_to_string_symbol,
     ]
     self._check(
         Arrangement(
             test_case,
             atc_symbol_usages=do_return(symbol_usages),
             atc_execute=execute_action_that_returns_exit_code(128)),
         Expectation(
             asrt_result.matches2(
                 None,
                 asrt_result.has_sds(),
                 asrt_result.has_action_to_check_outcome_with_exit_code(
                     128),
                 ExpectedFailureForNoFailure(),
             ),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE +
             PRE_SDS_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__MAIN,
                 phase_step.SETUP__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_POST_SETUP,
                 phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ASSERT__VALIDATE_POST_SETUP,
                 phase_step.ACT__VALIDATE_EXE_INPUT,
                 phase_step.ACT__PREPARE,
                 phase_step.ACT__EXECUTE,
                 phase_step.BEFORE_ASSERT__MAIN,
                 phase_step.ASSERT__MAIN,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT),
             ],
         ))
Пример #18
0
 def test_hard_error_exception(self):
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(PartialPhase.SETUP,
              test.setup_phase_instruction_that(
                  main=do_raise(hard_error_ex('hard error exception msg from setup'))))
     self._check(
         Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     phase_step.SETUP__MAIN,
                     test_case.the_extra(PartialPhase.SETUP)[0].source,
                     'hard error exception msg from setup'),
             ),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__TWICE +
             PRE_SDS_VALIDATION_STEPS__TWICE + [
                 phase_step.SETUP__MAIN,
                 (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP),
                 (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP),
             ],
         ))
 def test_reference_to_undefined_symbol_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     symbol_usages_with_ref_to_undefined_symbol = [
         data_references.reference_to__on_direct_and_indirect(
             'undefined_symbol')
     ]
     self._check(
         Arrangement(test_case,
                     atc_symbol_usages=do_return(
                         symbol_usages_with_ref_to_undefined_symbol)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.VALIDATION_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_step(
                     phase_step.ACT__VALIDATE_SYMBOLS),
             ),
             [
                 phase_step.ACT__PARSE,
                 phase_step.SETUP__VALIDATE_SYMBOLS,
                 phase_step.ACT__VALIDATE_SYMBOLS,
             ],
         ))