def test_validation_error_in_validate_post_setup(self):
        test_case = _single_successful_instruction_in_each_phase()
        self._check(
            Arrangement(test_case,
                        act_executor_validate_post_setup=validate_action_that_returns(
                            svh.new_svh_validation_error('error in act/validate-post-setup'))),
            Expectation(
                asrt_result.matches2(PartialExeResultStatus.VALIDATION_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),
                ],
            ))
Exemplo n.º 2
0
 def test_internal_error_in_act_execute(self):
     test_case = _single_successful_instruction_in_each_phase(
         single_line_sequence(72, 'ignored'))
     self._check(
         Arrangement(
             test_case,
             ActorThatRunsConstantActions(
                 execute_action=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)),
             atc_stdout_output=asrt.equals(''),
             atc_stderr_output=asrt.equals(''),
             step_recordings=[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),
             ],
         ))
    def test_implementation_error_in_execute(self):
        test_case = _single_successful_instruction_in_each_phase()
        self._check(
            Arrangement(test_case,
                        act_executor_execute=execute_action_that_raises(
                            test.ImplementationErrorTestException())),
            Expectation(
                asrt_result.matches2(PartialExeResultStatus.IMPLEMENTATION_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__PREPARE,
                 phase_step.ACT__EXECUTE,

                 (phase_step.CLEANUP__MAIN, PreviousPhase.ACT),
                 ],
            ))
Exemplo n.º 4
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),
             ],
         ))
    def test_hard_error_in_prepare(self):
        test_case = _single_successful_instruction_in_each_phase()
        self._check(
            Arrangement(test_case,
                        act_executor_prepare=prepare_action_that_returns_hard_error_with_message(
                            'error in act/prepare')),
            Expectation(
                asrt_result.matches2(PartialExeResultStatus.HARD_ERROR,
                                     asrt_result.has_sds(),
                                     asrt_result.has_no_action_to_check_outcome(),
                                     ExpectedFailureForPhaseFailure.new_with_message(
                                         phase_step.ACT__PREPARE,
                                         'error in act/prepare')
                                     ),
                [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__PREPARE,

                 (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,
             ],
         ))
 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_symbol_utils.symbol_reference(symbol_name,
                                                                     StringRestriction())
     definition_of_path_symbol = data_symbol_utils.file_ref_symbol_definition(symbol_name)
     symbol_usages = [
         definition_of_path_symbol,
         reference_to_string_symbol,
     ]
     self._check(
         Arrangement(test_case,
                     act_executor_symbol_usages=do_return(symbol_usages)),
         Expectation(
             asrt_result.matches2(
                 PartialExeResultStatus.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,
             ],
         ))
Exemplo n.º 8
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),
                        ],
                    ))
Exemplo n.º 9
0
    def test_implementation_error_in_act_execute(self):
        test_case = _single_successful_instruction_in_each_phase(single_line_sequence(72, 'ignored'))
        self._check(
            Arrangement(test_case,
                        ActorThatRunsConstantActions(
                            execute_action=execute_action_that_raises(
                                test.ImplementationErrorTestException()))),
            Expectation(
                asrt_result.matches2(PartialExeResultStatus.IMPLEMENTATION_ERROR,
                                     asrt_result.has_sds(),
                                     asrt_result.has_no_action_to_check_outcome(),
                                     ExpectedFailureForPhaseFailure.new_with_exception(
                                         phase_step.ACT__EXECUTE,
                                         test.ImplementationErrorTestException)
                                     ),
                atc_stdout_output=asrt.equals(''),
                atc_stderr_output=asrt.equals(''),
                step_recordings=
                [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__PREPARE,
                 phase_step.ACT__EXECUTE,

                 (phase_step.CLEANUP__MAIN, PreviousPhase.ACT),
                 ],
            ))
Exemplo n.º 10
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),
             ],
         ))
Exemplo n.º 11
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),
                ],
            ))
Exemplo n.º 12
0
 def test_implementation_error_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     act_executor_symbol_usages=do_raise(test.ImplementationErrorTestException())),
         Expectation(
             asrt_result.matches2(PartialExeResultStatus.IMPLEMENTATION_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,
             ],
         ))
Exemplo n.º 13
0
 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 = [symbol_reference('undefined_symbol')]
     self._check(
         Arrangement(test_case,
                     act_executor_symbol_usages=do_return(symbol_usages_with_ref_to_undefined_symbol)),
         Expectation(
             asrt_result.matches2(
                 PartialExeResultStatus.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,
             ],
         ))
Exemplo n.º 14
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,
             ],
         ))
Exemplo n.º 15
0
 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,
             ],
         ))
Exemplo n.º 16
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,
             ],
         ))
 def test_hard_error_in_validate_pre_sds(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     act_executor_validate_pre_sds=validate_action_that_returns(
                         svh.new_svh_hard_error('error in act/validate-pre-sds'))),
         Expectation(
             asrt_result.matches2(PartialExeResultStatus.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,
                                      'error 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,
             ],
         ))
Exemplo n.º 18
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),
             ],
         ))
Exemplo n.º 19
0
    def test_timeout_in_action_to_check(self):
        stdout_before_sleep = 'some output on stdout before going into sleep'
        stderr_before_sleep = 'some output on stderr before going into sleep'

        py_pgm_line_sequence = py_pgm_with_stdout_stderr_and_sleep_in_between(
            stdout_output_before_sleep=stdout_before_sleep,
            stderr_output_before_sleep=stderr_before_sleep,
            stdout_output_after_sleep='more stdout output after sleep',
            stderr_output_after_sleep='more stderr output after sleep',
            sleep_seconds=3,
            exit_code=72)
        test_case = _single_successful_instruction_in_each_phase(
            act_phase_source=py_pgm_line_sequence)
        self._check(
            arr_for_py3_source(test_case, timeout_in_seconds=1),
            Expectation(
                asrt_result.matches2(
                    ExecutionFailureStatus.HARD_ERROR, asrt_result.has_sds(),
                    asrt_result.has_no_action_to_check_outcome(),
                    ExpectedFailureForPhaseFailure(phase_step.ACT__EXECUTE,
                                                   asrt.anything_goes())),
                atc_stdout_output=asrt.equals(stdout_before_sleep),
                atc_stderr_output=asrt.equals(stderr_before_sleep),
                step_recordings=[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),
                ],
            ))
Exemplo n.º 20
0
 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,
             ],
         ))