Exemple #1
0
    def test_assert(self):
        # ARRANGE #
        cases = {
            EXECUTION__VALIDATION_ERROR:
                assert_phase_instruction_that(validate_pre_sds=SVH_VALIDATION_ERROR),

            EXECUTION__HARD_ERROR:
                assert_phase_instruction_that(validate_pre_sds=SVH_HARD_ERROR),

            EXECUTION__IMPLEMENTATION_ERROR:
                assert_phase_instruction_that(validate_pre_sds_initial_action=DO_RAISES_EXCEPTION),
        }
        # ACT & ASSERT #
        self._check_and_assert_sds_is_not_created_and_stdout_is_empty(phase_identifier.ASSERT, cases)
Exemple #2
0
 def test_assert(self):
     # ARRANGE #
     cases = {
         EXECUTION__VALIDATION_ERROR:
         assert_phase_instruction_that(
             validate_pre_sds=SVH_VALIDATION_ERROR),
         EXECUTION__HARD_ERROR:
         assert_phase_instruction_that(validate_pre_sds=SVH_HARD_ERROR),
         EXECUTION__INTERNAL_ERROR:
         assert_phase_instruction_that(
             validate_pre_sds_initial_action=DO_RAISES_EXCEPTION),
     }
     # ACT & ASSERT #
     self._check_and_assert_sds_is_not_created_and_stdout_is_empty(
         phase_identifier.ASSERT, cases)
Exemple #3
0
 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=_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_that_symbols_from_arrangement_exist_in_environment(self):
        symbol_name = 'symbol_name'
        symbol_value = 'the symbol value'
        symbol_table_of_arrangement = data_symbol_utils.symbol_table_with_single_string_value(symbol_name,
                                                                                              symbol_value)
        expected_symbol_table = data_symbol_utils.symbol_table_with_single_string_value(symbol_name,
                                                                                        symbol_value)
        assertion_for_validation = do_fail_if_symbol_table_does_not_equal(
            self,
            expected_symbol_table,
            get_symbol_table_from_path_resolving_environment_that_is_first_arg)

        assertion_for_main = do_fail_if_symbol_table_does_not_equal(
            self,
            expected_symbol_table,
            get_symbol_table_from_instruction_environment_that_is_first_arg)

        self._check(
            utils.ParserThatGives(
                assert_phase_instruction_that(
                    validate_pre_sds_initial_action=assertion_for_validation,
                    validate_post_setup_initial_action=assertion_for_validation,
                    main_initial_action=assertion_for_main,
                )),
            utils.single_line_source(),
            sut.ArrangementPostAct(
                symbols=symbol_table_of_arrangement),
            sut.Expectation(),
        )
    def test_instruction_environment_specifies_correct_tmp_dir_space_for_each_instruction(
            self):
        # ARRANGE #
        recorder = {}

        setup_phase_instr_that_records = setup_phase_instruction_that(
            validate_post_setup_initial_action=
            RecordTmpDirForInstructionInPhase(PhaseEnum.SETUP, recorder),
            main_initial_action=RecordTmpDirForInstructionInPhase(
                PhaseEnum.SETUP, recorder).call,
        )
        before_assert_phase_instr_that_records = before_assert_phase_instruction_that(
            validate_post_setup_initial_action=
            RecordTmpDirForInstructionInPhase(PhaseEnum.BEFORE_ASSERT,
                                              recorder),
            main_initial_action=RecordTmpDirForInstructionInPhase(
                PhaseEnum.BEFORE_ASSERT, recorder).call)
        assert_phase_instr_that_records = assert_phase_instruction_that(
            validate_post_setup_initial_action=
            RecordTmpDirForInstructionInPhase(PhaseEnum.ASSERT, recorder),
            main_initial_action=RecordTmpDirForInstructionInPhase(
                PhaseEnum.ASSERT, recorder).call)
        cleanup_phase_instr_that_records = cleanup_phase_instruction_that(
            main_initial_action=RecordTmpDirForInstructionInPhase(
                PhaseEnum.CLEANUP, recorder).call)
        test_case = partial_test_case_with_instructions(
            [
                setup_phase_instr_that_records,
                setup_phase_instr_that_records,
            ],
            [act_phase_instruction_with_source(LineSequence(1, ('line', )))],
            [
                before_assert_phase_instr_that_records,
                before_assert_phase_instr_that_records,
            ],
            [
                assert_phase_instr_that_records,
                assert_phase_instr_that_records,
            ],
            [
                cleanup_phase_instr_that_records,
                cleanup_phase_instr_that_records,
            ],
        )
        actor_that_registers_tmp_dirs = ActorThatRunsConstantActions(
            validate_post_setup_initial_action=
            RecordTmpDirForInstructionInPhase(PhaseEnum.ACT, recorder),
            prepare_initial_action=RecordTmpDirForInstructionInPhase(
                PhaseEnum.ACT, recorder),
            execute_initial_action=RecordTmpDirForInstructionInPhase(
                PhaseEnum.ACT, recorder),
        )
        # ACT & ASSERT #
        test(self,
             test_case,
             actor_that_registers_tmp_dirs,
             functools.partial(tmp_dir_is_correct_for_each_instruction,
                               recorder, 2),
             is_keep_sandbox=False)
Exemple #7
0
def assert_phase_instruction_that_records_property_of_env_for_each_step(
        property_recorder: PropertyRecorderBuilder) -> AssertPhaseInstruction:
    return assert_phase_instruction_that(
        validate_pre_sds_initial_action=property_recorder.of_first_arg(
            step.ASSERT__VALIDATE_PRE_SDS),
        validate_post_setup_initial_action=property_recorder.of_first_arg(
            step.ASSERT__VALIDATE_POST_SETUP),
        main_initial_action=property_recorder.of_first_arg(step.ASSERT__MAIN))
def assert_phase_instruction_that_records_a_value_per_step(
        recorder_for) -> AssertPhaseInstruction:
    return assert_phase_instruction_that(
        validate_pre_sds_initial_action=recorder_for(
            step.ASSERT__VALIDATE_PRE_SDS),
        validate_post_setup_initial_action=recorder_for(
            step.ASSERT__VALIDATE_POST_SETUP),
        main_initial_action=recorder_for(step.ASSERT__MAIN),
    )
Exemple #9
0
 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 new_assert_instruction(self,
                            value_for_symbol_usages,
                            value_for_validate_pre_sds,
                            value_for_validate,
                            value_for_execute) -> AssertPhaseInstruction:
     return assert_phase_instruction_that(
         symbol_usages_initial_action=self._do_record_first_invokation(value_for_symbol_usages),
         validate_pre_sds=self._do_record_and_return_svh(value_for_validate_pre_sds),
         validate_post_setup=self._do_record_and_return_svh(value_for_validate),
         main=self._do_record_and_return(value_for_execute,
                                         pfh.new_pfh_pass()))
 def test_that_default_expectation_assumes_no_symbol_usages(self):
     with self.assertRaises(utils.TestError):
         unexpected_symbol_usages = [data_symbol_utils.symbol_reference('symbol_name')]
         self._check(
             utils.ParserThatGives(
                 assert_phase_instruction_that(
                     symbol_usages=do_return(unexpected_symbol_usages))),
             utils.single_line_source(),
             sut.ArrangementPostAct(),
             sut.Expectation(),
         )
 def new_assert_instruction(self, value_for_symbol_usages,
                            value_for_validate_pre_sds, value_for_validate,
                            value_for_execute) -> AssertPhaseInstruction:
     return assert_phase_instruction_that(
         symbol_usages_initial_action=self._do_record_first_invokation(
             value_for_symbol_usages),
         validate_pre_sds=self._do_record_and_return_svh(
             value_for_validate_pre_sds),
         validate_post_setup=self._do_record_and_return_svh(
             value_for_validate),
         main=self._do_record_and_return(value_for_execute,
                                         pfh.new_pfh_pass()))
Exemple #13
0
 def test_assert(self):
     # ARRANGE #
     cases = {
         STEP__VALIDATE_POST_SETUP: {
             EXECUTION__VALIDATION_ERROR:
             assert_phase_instruction_that(
                 validate_post_setup=SVH_VALIDATION_ERROR),
             EXECUTION__HARD_ERROR:
             assert_phase_instruction_that(
                 validate_post_setup=SVH_HARD_ERROR),
             EXECUTION__INTERNAL_ERROR:
             assert_phase_instruction_that(
                 validate_post_setup_initial_action=DO_RAISES_EXCEPTION),
         },
         STEP__MAIN: {
             EXECUTION__FAIL:
             assert_phase_instruction_that(
                 main=do_return(pfh.new_pfh_fail__str('fail msg'))),
             EXECUTION__HARD_ERROR:
             assert_phase_instruction_that(main=do_return(
                 pfh.new_pfh_hard_error__str('hard error msg'))),
             EXECUTION__INTERNAL_ERROR:
             assert_phase_instruction_that(
                 main_initial_action=DO_RAISES_EXCEPTION),
         },
     }
     # ACT & ASSERT #
     self._check_and_assert_sds_is_preserved_and_is_printed(
         phase_identifier.ASSERT, cases)
Exemple #14
0
    def test_assert(self):
        # ARRANGE #
        cases = {
            STEP__VALIDATE_POST_SETUP:
                {
                    EXECUTION__VALIDATION_ERROR:
                        assert_phase_instruction_that(validate_post_setup=SVH_VALIDATION_ERROR),

                    EXECUTION__HARD_ERROR:
                        assert_phase_instruction_that(validate_post_setup=SVH_HARD_ERROR),

                    EXECUTION__IMPLEMENTATION_ERROR:
                        assert_phase_instruction_that(validate_post_setup_initial_action=DO_RAISES_EXCEPTION),

                },
            STEP__MAIN:
                {
                    EXECUTION__FAIL:
                        assert_phase_instruction_that(main=do_return(pfh.new_pfh_fail('fail msg'))),

                    EXECUTION__HARD_ERROR:
                        assert_phase_instruction_that(main=do_return(pfh.new_pfh_hard_error('hard error msg'))),

                    EXECUTION__IMPLEMENTATION_ERROR:
                        assert_phase_instruction_that(main_initial_action=DO_RAISES_EXCEPTION),
                },
        }
        # ACT & ASSERT #
        self._check_and_assert_sds_is_preserved_and_is_printed(phase_identifier.ASSERT, cases)
Exemple #15
0
def configuration_with_assert_instruction_that_fails(instruction_name: str) -> sut.Configuration:
    assert_instruction_setup = instr_setup(instr.assert_phase_instruction_that(
        main=do_return(pfh.new_pfh_fail('fail error message')))
    )

    instruction_set = InstructionsSetup(
        config_instruction_set={},
        setup_instruction_set={},
        before_assert_instruction_set={},
        assert_instruction_set={instruction_name: assert_instruction_setup},
        cleanup_instruction_set={},
    )
    return configuration_for_instruction_set(instruction_set)
 def test_that_fails_due_to_missing_symbol_reference(self):
     with self.assertRaises(utils.TestError):
         symbol_usages_of_instruction = []
         symbol_usages_of_expectation = [data_symbol_utils.symbol_reference('symbol_name')]
         self._check(
             utils.ParserThatGives(
                 assert_phase_instruction_that(
                     symbol_usages=do_return(symbol_usages_of_instruction))),
             utils.single_line_source(),
             sut.ArrangementPostAct(),
             sut.Expectation(
                 symbol_usages=sym_asrt.equals_symbol_references(symbol_usages_of_expectation)),
         )
 def test_that_default_expectation_assumes_no_symbol_usages(self):
     with self.assertRaises(utils.TestError):
         unexpected_symbol_usages = [
             data_references.reference_to__on_direct_and_indirect(
                 'symbol_name')
         ]
         self._check(
             utils.ParserThatGives(
                 assert_phase_instruction_that(
                     symbol_usages=do_return(unexpected_symbol_usages))),
             utils.single_line_source(),
             sut.ArrangementPostAct(),
             sut.Expectation(),
         )
Exemple #18
0
def configuration_with_assert_instruction_that_fails(
        instruction_name: str) -> sut.Configuration:
    assert_instruction_setup = instr_setup(
        instr.assert_phase_instruction_that(
            main=do_return(pfh.new_pfh_fail__str('fail error message'))))

    instruction_set = InstructionsSetup(
        config_instruction_set={},
        setup_instruction_set={},
        before_assert_instruction_set={},
        assert_instruction_set={instruction_name: assert_instruction_setup},
        cleanup_instruction_set={},
    )
    return configuration_for_instruction_set(instruction_set)
 def test_that_fails_due_to_missing_symbol_reference(self):
     with self.assertRaises(utils.TestError):
         symbol_usages_of_instruction = []
         self._check(
             utils.ParserThatGives(
                 assert_phase_instruction_that(symbol_usages=do_return(
                     symbol_usages_of_instruction))),
             utils.single_line_source(),
             sut.ArrangementPostAct(),
             sut.Expectation(symbol_usages=asrt.matches_singleton_sequence(
                 matches_data_type_symbol_reference(
                     'symbol_name',
                     reference_restrictions.is_any_type_w_str_rendering()))
                             ),
         )
 def test_instruction_environment_specifies_correct_log_dir_for_each_phase(self):
     recorder = {}
     test_case = partial_test_case_with_instructions(
         [setup_phase_instruction_that(main_initial_action=RecordLogDirForPhase(PhaseEnum.SETUP, recorder))],
         [act_phase_instruction_with_source(LineSequence(1, ('line',)))],
         [before_assert_phase_instruction_that(main_initial_action=RecordLogDirForPhase(PhaseEnum.BEFORE_ASSERT,
                                                                                        recorder))],
         [assert_phase_instruction_that(main_initial_action=RecordLogDirForPhase(PhaseEnum.ASSERT, recorder))],
         [cleanup_phase_instruction_that(main_initial_action=RecordLogDirForPhase(PhaseEnum.CLEANUP, recorder))],
     )
     test(
         self,
         test_case,
         dummy_actor(),
         functools.partial(log_dir_is_correct_for_each_phase, recorder),
         is_keep_sandbox=False)
Exemple #21
0
    def test_with_assert_phase_that_fails(self):
        test_case = test_case_with_two_instructions_in_each_phase() \
            .add(phase_identifier.CONFIGURATION,
                 test.ConfigurationPhaseInstructionThatSetsExecutionMode(TestCaseStatus.FAIL)) \
            .add(phase_identifier.ASSERT,
                 test.assert_phase_instruction_that(
                     main=do_return(pfh.new_pfh_fail('fail message'))))
        self._check(Arrangement(test_case,
                                execute_test_action=execute_action_that_returns_exit_code(11)),
                    Expectation(
                        asrt_result.matches2(
                            FullExeResultStatus.XFAIL,
                            asrt_result.has_sds(),
                            asrt_result.has_action_to_check_outcome_with_exit_code(11),
                            ExpectedFailureForInstructionFailure.new_with_message(
                                phase_step.ASSERT__MAIN,
                                test_case.the_extra(phase_identifier.ASSERT)[0].source,
                                'fail message'),
                        ),
                        [phase_step.CONFIGURATION__MAIN,
                         phase_step.CONFIGURATION__MAIN] +
                        [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__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),
                         ],
                    ))
Exemple #22
0
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_set_environment_variable_in_phase_assert(self):
        recorder = _RecorderOfExistenceOfGlobalEnvVar(_unique_variable_name())

        test_case = partial_test_case_with_instructions(
            [],
            _act_phase_instructions_that_are_not_relevant_to_this_test(),
            [],
            [assert_phase_instruction_that(
                main_initial_action=Sequence([SetEnvironmentVariableViaInstructionArguments(recorder.variable_name),
                                              recorder.for_step(step.ASSERT__MAIN)]))],
            [cleanup_phase_instruction_that(
                main_initial_action=recorder.for_step(step.CLEANUP__MAIN))],
        )
        test__va(
            self,
            test_case,
            Arrangement(actor=dummy_actor()),
            AssertPhasesWhereTheEnvironmentVariableExistsInTheGlobalEnvironmentIsEmpty(recorder.recorded_steps))
Exemple #24
0
 def test_with_assert_phase_that_fails(self):
     test_case = test_case_with_two_instructions_in_each_phase() \
         .add(phase_identifier.CONFIGURATION,
              test.ConfigurationPhaseInstructionThatSetsExecutionMode(TestCaseStatus.FAIL)) \
         .add(phase_identifier.ASSERT,
              test.assert_phase_instruction_that(
                  main=do_return(pfh.new_pfh_fail__str('fail message'))))
     self._check(
         Arrangement(
             test_case,
             execute_test_action=execute_action_that_returns_exit_code(11)),
         Expectation(
             asrt_result.matches2(
                 FullExeResultStatus.XFAIL,
                 asrt_result.has_sds(),
                 asrt_result.has_action_to_check_outcome_with_exit_code(11),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     phase_step.ASSERT__MAIN,
                     test_case.the_extra(phase_identifier.ASSERT)[0].source,
                     'fail message'),
             ),
             [
                 phase_step.CONFIGURATION__MAIN,
                 phase_step.CONFIGURATION__MAIN
             ] + [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__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),
             ],
         ))
Exemple #25
0
    def test_implementation_error_in_assert_main_step(self):
        test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
            .add(PartialPhase.ASSERT,
                 test.assert_phase_instruction_that(
                     main=do_raise(test.ImplementationErrorTestException())))
        self._check(
            Arrangement(test_case,
                        act_executor_execute=execute_action_that_returns_exit_code(5)),
            Expectation(
                asrt_result.matches2(
                    PartialExeResultStatus.IMPLEMENTATION_ERROR,
                    asrt_result.has_sds(),
                    asrt_result.has_action_to_check_outcome_with_exit_code(5),
                    ExpectedFailureForInstructionFailure.new_with_exception(
                        phase_step.ASSERT__MAIN,
                        test_case.the_extra(PartialPhase.ASSERT)[0].source,
                        test.ImplementationErrorTestException),
                ),
                [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__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),
                 ],
            ))
Exemple #26
0
 def test_internal_error(self):
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(PartialPhase.ASSERT,
              test.assert_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_action_to_check_outcome_with_exit_code(5),
                 ExpectedFailureForInstructionFailure.new_with_exception(
                     phase_step.ASSERT__MAIN,
                     test_case.the_extra(PartialPhase.ASSERT)[0].source,
                     test.ImplementationErrorTestException),
             ),
             [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_that_symbols_from_arrangement_exist_in_environment(self):
        symbol = StringConstantSymbolContext('symbol_name', 'the symbol value')
        symbol_table_of_arrangement = symbol.symbol_table
        expected_symbol_table = symbol.symbol_table
        assertion_for_validation = do_fail_if_symbol_table_does_not_equal(
            self, expected_symbol_table,
            get_symbol_table_from_path_resolving_environment_that_is_first_arg)

        assertion_for_main = do_fail_if_symbol_table_does_not_equal(
            self, expected_symbol_table,
            get_symbol_table_from_instruction_environment_that_is_first_arg)

        self._check(
            utils.ParserThatGives(
                assert_phase_instruction_that(
                    validate_pre_sds_initial_action=assertion_for_validation,
                    validate_post_setup_initial_action=assertion_for_validation,
                    main_initial_action=assertion_for_main,
                )),
            utils.single_line_source(),
            sut.ArrangementPostAct(symbols=symbol_table_of_arrangement),
            sut.Expectation(),
        )
 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 test_set_environment_variable_in_phase_setup(self):
        recorder = _RecorderOfExistenceOfGlobalEnvVar(_unique_variable_name())

        test_case = partial_test_case_with_instructions(
            [setup_phase_instruction_that(
                main_initial_action=Sequence([SetEnvironmentVariableViaInstructionArguments(recorder.variable_name),
                                              recorder.for_step(step.SETUP__MAIN)]),
                validate_post_setup_initial_action=recorder.for_step(step.SETUP__VALIDATE_POST_SETUP))],
            _act_phase_instructions_that_are_not_relevant_to_this_test(),
            [before_assert_phase_instruction_that(
                validate_post_setup_initial_action=recorder.for_step(step.BEFORE_ASSERT__VALIDATE_POST_SETUP),
                main_initial_action=recorder.for_step(step.BEFORE_ASSERT__MAIN))],
            [assert_phase_instruction_that(
                validate_post_setup_initial_action=recorder.for_step(step.ASSERT__VALIDATE_POST_SETUP),
                main_initial_action=recorder.for_step(step.ASSERT__MAIN))],
            [cleanup_phase_instruction_that(
                main_initial_action=recorder.for_step(step.CLEANUP__MAIN))],
        )
        test__va(
            self,
            test_case,
            Arrangement(
                actor=_actor_that_records_existence_of_var_in_global_env(recorder)),
            AssertPhasesWhereTheEnvironmentVariableExistsInTheGlobalEnvironmentIsEmpty(recorder.recorded_steps))
    'ASSERT_PHASE_INSTRUCTION_THAT_PASS_IFF_STDOUT_EQUALS'

ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY__NAME = 'ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY'


def test_suite_definition_with_single_conf_instruction(name: str,
                                                       instruction: ConfigurationSectionInstruction
                                                       ) -> TestSuiteDefinition:
    configuration_section_instructions = {
        name: single_instruction_setup(name, instruction)

    }
    return test_suite_definition_with_instructions(configuration_section_instructions)


ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY = assert_phase_instruction_that(
    main=do_return(pfh.new_pfh_fail('unconditional failure')))


def assert_phase_instruction_that_pass_iff_stdout_is_success_indicator_string(expected: str) -> AssertPhaseInstruction:
    return AssertPhaseInstructionThatPassIffStdoutEqualsString(expected)


class AssertPhaseInstructionThatPassIffStdoutEqualsString(AssertPhaseInstruction):
    def __init__(self, expected: str):
        self.expected = expected

    def main(self,
             environment: InstructionEnvironmentForPostSdsStep,
             os_services: OsServices) -> pfh.PassOrFailOrHardError:
        actual_contents = environment.sds.result.stdout_file.read_text()
        if actual_contents == self.expected:
 def instruction_that_returns(self, symbol_usages: list) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(symbol_usages=do_return(symbol_usages))
    def test_one_symbol_is_defined_in_the_assert_phase(self):
        symbol = NameAndValue('symbol name', 'symbol value (not used in test)')
        all_defined_symbols = {symbol.name}
        symbol_definition = StringConstantSymbolContext(
            symbol.name, symbol.value).definition
        symbol_usages_of_instruction_that_defines_symbol = [symbol_definition]

        expected_phase_2_step_2_names_set = {
            PhaseEnum.SETUP: {
                step.SETUP__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.SETUP__MAIN.step: set(),
                step.SETUP__VALIDATE_POST_SETUP.step: all_defined_symbols,
            },
            PhaseEnum.ACT: {
                step.ACT__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.ACT__VALIDATE_POST_SETUP.step: all_defined_symbols,
                step.ACT__EXECUTE.step: set(),
                step.ACT__PREPARE.step: set(),
            },
            PhaseEnum.BEFORE_ASSERT: {
                step.BEFORE_ASSERT__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.BEFORE_ASSERT__MAIN.step: set(),
                step.BEFORE_ASSERT__VALIDATE_POST_SETUP.step:
                all_defined_symbols,
            },
            PhaseEnum.ASSERT: {
                step.ASSERT__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.ASSERT__MAIN.step: set(),
                step.ASSERT__VALIDATE_POST_SETUP.step: all_defined_symbols,
            },
            PhaseEnum.CLEANUP:
            psr.same_value_for_all_steps(step.ALL_CLEANUP_WITH_ENV_ARG,
                                         all_defined_symbols),
        }
        actual_phase_2_step_2_names_set = psr.new_phase_enum_2_empty_dict()

        def recorder_for(phase_step: SimplePhaseStep):
            return psr.StepRecordingAction(
                phase_step, actual_phase_2_step_2_names_set,
                get_symbols_name_set_from_instruction_environment)

        test_case = partial_test_case_with_instructions(
            [
                psr.setup_phase_instruction_that_records_a_value_per_step(
                    recorder_for)
            ],
            psr.act_phase_instructions_that_does_nothing(),
            [
                psr.
                before_assert_phase_instruction_that_records_a_value_per_step(
                    recorder_for)
            ],
            [
                assert_phase_instruction_that(
                    symbol_usages=do_return(
                        symbol_usages_of_instruction_that_defines_symbol),
                    validate_pre_sds_initial_action=recorder_for(
                        step.ASSERT__VALIDATE_PRE_SDS),
                    main_initial_action=sequence_of_actions([
                        recorder_for(step.ASSERT__MAIN),
                        _ActionThatSetsSymbolInSymbolTable(symbol_definition),
                    ]),
                    validate_post_setup_initial_action=recorder_for(
                        step.ASSERT__VALIDATE_POST_SETUP),
                )
            ],
            [
                psr.cleanup_phase_instruction_that_records_a_value_per_step(
                    recorder_for)
            ],
        )
        test__va(
            self, test_case,
            Arrangement(
                psr.actor_that_records_a_value_per_step(
                    recorder_for, recorder_for_parse_step=psr.no_recording)),
            asrt.anything_goes())
        _check_result(self, expected_phase_2_step_2_names_set,
                      actual_phase_2_step_2_names_set)
Exemple #33
0
 def assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(instr.assert_phase_instruction_that(
         main_initial_action=do_raise(ImplementationError())
     ))
Exemple #34
0
 def mk_instruction_with_main_action(self, main_action: Callable) -> Instruction:
     return assert_phase_instruction_that(main_initial_action=main_action)
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(validate_pre_sds=do_raise(exception))
Exemple #36
0
 def assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(
         instr.assert_phase_instruction_that(
             main_initial_action=append_section_name_action(
                 self.recording_output, phase_identifier.ASSERT)))
Exemple #37
0
 def assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(
         instr.assert_phase_instruction_that(
             main_initial_action=do_raise(ImplementationError())))
Exemple #38
0
 def assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(instr.assert_phase_instruction_that(
         main_initial_action=append_section_name_action(self.recording_output, phase_identifier.ASSERT))
     )
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(symbol_usages=do_raise(exception))
Exemple #40
0
def assert_phase_instruction_that_records_property_of_env_for_each_step(
        property_recorder: PropertyRecorderBuilder) -> AssertPhaseInstruction:
    return assert_phase_instruction_that(
        validate_pre_sds_initial_action=property_recorder.of_first_arg(step.ASSERT__VALIDATE_PRE_SDS),
        validate_post_setup_initial_action=property_recorder.of_first_arg(step.ASSERT__VALIDATE_POST_SETUP),
        main_initial_action=property_recorder.of_first_arg(step.ASSERT__MAIN))
        DEF_INSTRUCTION_NAME: define_symbol__setup.setup(DEF_INSTRUCTION_NAME),
        REF_INSTRUCTION_NAME: _ref_instruction_setup(
            REF_INSTRUCTION_NAME,
            lambda usages: instrs.setup_phase_instruction_that(symbol_usages=do_return(usages))),
    },
    before_assert_instruction_set={
        DEF_INSTRUCTION_NAME: define_symbol__before_assert.setup(DEF_INSTRUCTION_NAME),
        REF_INSTRUCTION_NAME: _ref_instruction_setup(
            REF_INSTRUCTION_NAME,
            lambda usages: instrs.before_assert_phase_instruction_that(symbol_usages=do_return(usages))),
    },
    assert_instruction_set={
        DEF_INSTRUCTION_NAME: define_symbol__assert.setup(DEF_INSTRUCTION_NAME),
        REF_INSTRUCTION_NAME: _ref_instruction_setup(
            REF_INSTRUCTION_NAME,
            lambda usages: instrs.assert_phase_instruction_that(symbol_usages=do_return(usages))),
    },
    cleanup_instruction_set={
        DEF_INSTRUCTION_NAME: define_symbol__cleanup.setup(DEF_INSTRUCTION_NAME),
        REF_INSTRUCTION_NAME: _ref_instruction_setup(
            REF_INSTRUCTION_NAME,
            lambda usages: instrs.cleanup_phase_instruction_that(symbol_usages=do_return(usages))),
    },
)


def main_program_config(actor: Optional[Actor] = None) -> MainProgramConfig:
    if actor is None:
        actor = _ActorThatParsesReferences(REF_INSTRUCTION_NAME)
    return main_program_execution.main_program_config(
        test_case_definition_for(INSTRUCTION_SETUP),
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(validate_pre_sds=do_raise(exception))
 def instruction_that_returns(self, return_value: svh.SuccessOrValidationErrorOrHardError) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(
         validate_pre_sds=do_return(return_value))
Exemple #44
0
 def instruction_that_returns(self, symbol_usages: list) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(symbol_usages=do_return(symbol_usages))
Exemple #45
0
    'ASSERT_PHASE_INSTRUCTION_THAT_PASS_IFF_STDOUT_EQUALS'

ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY__NAME = 'ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY'


def test_suite_definition_with_single_conf_instruction(name: str,
                                                       instruction: ConfigurationSectionInstruction
                                                       ) -> TestSuiteDefinition:
    configuration_section_instructions = {
        name: single_instruction_setup(name, instruction)

    }
    return test_suite_definition_with_instructions(configuration_section_instructions)


ASSERT_PHASE_INSTRUCTION_THAT_FAILS_UNCONDITIONALLY = assert_phase_instruction_that(
    main=do_return(pfh.new_pfh_fail__str('unconditional failure')))


def assert_phase_instruction_that_pass_iff_stdout_is_success_indicator_string(expected: str) -> AssertPhaseInstruction:
    return AssertPhaseInstructionThatPassIffStdoutEqualsString(expected)


class AssertPhaseInstructionThatPassIffStdoutEqualsString(AssertPhaseInstruction):
    def __init__(self, expected: str):
        self.expected = expected

    def main(self,
             environment: InstructionEnvironmentForPostSdsStep,
             settings: InstructionSettings,
             os_services: OsServices) -> pfh.PassOrFailOrHardError:
        actual_contents = environment.sds.result.stdout_file.read_text()
            sut.ArrangementPostAct(
                default_environ_getter=default_environ_getter,
                process_execution_settings=ProcessExecutionSettings.
                from_non_immutable(environ=default_environs),
            ),
            sut.Expectation(instruction_settings=asrt_instr_settings.matches(
                environ=asrt.equals(default_environs),
                return_value_from_default_getter=asrt.equals(
                    default_from_default_getter)),
                            proc_exe_settings=asrt_pes.matches(
                                environ=asrt.equals(default_environs))),
        )


PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION = utils.ParserThatGives(
    assert_phase_instruction_that())


class TestSymbolUsages(TestCaseBase):
    def test_that_default_expectation_assumes_no_symbol_usages(self):
        with self.assertRaises(utils.TestError):
            unexpected_symbol_usages = [
                data_references.reference_to__on_direct_and_indirect(
                    'symbol_name')
            ]
            self._check(
                utils.ParserThatGives(
                    assert_phase_instruction_that(
                        symbol_usages=do_return(unexpected_symbol_usages))),
                utils.single_line_source(),
                sut.ArrangementPostAct(),
Exemple #47
0
 def _assert_phase(self) -> list:
     return self._phase_elements(lambda main: assert_phase_instruction_that(main=main),
                                 PhaseEnum.ASSERT)
Exemple #48
0
 def assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(
         instr.assert_phase_instruction_that(
             validate_pre_sds=self.do_return_validation_error))
    def test_one_symbol_is_defined_in_the_assert_phase(self):
        symbol = NameAndValue('symbol name',
                              'symbol value (not used in test)')
        all_defined_symbols = {symbol.name}
        symbol_definition = data_symbol_utils.string_symbol_definition(symbol.name, symbol.value)
        symbol_usages_of_instruction_that_defines_symbol = [symbol_definition]

        expected_phase_2_step_2_names_set = {
            PhaseEnum.SETUP: {
                step.SETUP__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.SETUP__MAIN.step: set(),
                step.SETUP__VALIDATE_POST_SETUP.step: all_defined_symbols,
            },
            PhaseEnum.ACT: {
                step.ACT__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.ACT__VALIDATE_POST_SETUP.step: all_defined_symbols,
                step.ACT__EXECUTE.step: set(),
                step.ACT__PREPARE.step: set(),
            },
            PhaseEnum.BEFORE_ASSERT: {
                step.BEFORE_ASSERT__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.BEFORE_ASSERT__MAIN.step: set(),
                step.BEFORE_ASSERT__VALIDATE_POST_SETUP.step: all_defined_symbols,
            },
            PhaseEnum.ASSERT: {
                step.ASSERT__VALIDATE_PRE_SDS.step: all_defined_symbols,
                step.ASSERT__MAIN.step: set(),
                step.ASSERT__VALIDATE_POST_SETUP.step: all_defined_symbols,
            },
            PhaseEnum.CLEANUP: psr.same_value_for_all_steps(step.ALL_CLEANUP_WITH_ENV_ARG, all_defined_symbols),
        }
        actual_phase_2_step_2_names_set = psr.new_phase_enum_2_empty_dict()

        def recorder_for(phase_step: SimplePhaseStep):
            return psr.StepRecordingAction(phase_step,
                                           actual_phase_2_step_2_names_set,
                                           get_symbols_name_set_from_instruction_environment)

        test_case = partial_test_case_with_instructions(
            [
                psr.setup_phase_instruction_that_records_a_value_per_step(recorder_for)
            ],
            psr.act_phase_instructions_that_does_nothing(),
            [
                psr.before_assert_phase_instruction_that_records_a_value_per_step(recorder_for)
            ],
            [
                assert_phase_instruction_that(
                    symbol_usages=do_return(symbol_usages_of_instruction_that_defines_symbol),
                    validate_pre_sds_initial_action=recorder_for(step.ASSERT__VALIDATE_PRE_SDS),
                    main_initial_action=Sequence([
                        recorder_for(step.ASSERT__MAIN),
                        _ActionThatSetsSymbolInSymbolTable(symbol_definition),
                    ]),
                    validate_post_setup_initial_action=recorder_for(step.ASSERT__VALIDATE_POST_SETUP),
                )
            ],
            [
                psr.cleanup_phase_instruction_that_records_a_value_per_step(recorder_for)
            ],
        )
        test__va(
            self,
            test_case,
            Arrangement(psr.actor_that_records_a_value_per_step(recorder_for,
                                                                recorder_for_parse_step=psr.no_recording)),
            asrt.anything_goes())
        _check_result(self,
                      expected_phase_2_step_2_names_set,
                      actual_phase_2_step_2_names_set)
 def instruction_that_returns(self, return_value: svh.SuccessOrValidationErrorOrHardError) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(
         validate_pre_sds=do_return(return_value))
Exemple #51
0
 def _assert_phase(self) -> list:
     return self._phase_elements(
         lambda main: assert_phase_instruction_that(main=main),
         PhaseEnum.ASSERT)
def assert_phase_instruction_that_records_a_value_per_step(recorder_for) -> AssertPhaseInstruction:
    return assert_phase_instruction_that(
        validate_pre_sds_initial_action=recorder_for(step.ASSERT__VALIDATE_PRE_SDS),
        validate_post_setup_initial_action=recorder_for(step.ASSERT__VALIDATE_POST_SETUP),
        main_initial_action=recorder_for(step.ASSERT__MAIN),
    )
Exemple #53
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(symbol_usages=do_raise(exception))
        populated_dir_contents = DirContents([empty_file('sds-file.txt')])
        self._check(
            PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION,
            utils.single_line_source(),
            sut.ArrangementPostAct(
                sds_contents=sds_populator.contents_in(
                    sds_populator.RelSdsOptionType.REL_TMP,
                    populated_dir_contents)),
            sut.Expectation(
                main_side_effects_on_sds=tmp_user_dir_contains_exactly(
                    populated_dir_contents)),
        )


PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION = utils.ParserThatGives(
    assert_phase_instruction_that())


class TestSymbolUsages(TestCaseBase):
    def test_that_default_expectation_assumes_no_symbol_usages(self):
        with self.assertRaises(utils.TestError):
            unexpected_symbol_usages = [data_symbol_utils.symbol_reference('symbol_name')]
            self._check(
                utils.ParserThatGives(
                    assert_phase_instruction_that(
                        symbol_usages=do_return(unexpected_symbol_usages))),
                utils.single_line_source(),
                sut.ArrangementPostAct(),
                sut.Expectation(),
            )
Exemple #55
0
 def assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(instr.assert_phase_instruction_that(
         validate_pre_sds=self.do_return_validation_error)
     )