Exemplo n.º 1
0
 def test_symbol_usages_of_object_returned_by_parser_SHOULD_be_reported(
         self):
     # ARRANGE #
     symbol_reference = NameAndValue(
         'symbol_name',
         reference_restrictions.is_any_type_w_str_rendering())
     expected_symbol_references = [
         SymbolReference(symbol_reference.name, symbol_reference.value)
     ]
     actor = sut.ActorFromParts(
         ParserWithConstantResult(
             SymbolUserWithConstantSymbolReferences(
                 expected_symbol_references)),
         sut.UnconditionallySuccessfulValidatorConstructor(),
         _ExecutorConstructorForConstant(
             UnconditionallySuccessfulExecutor()),
     )
     # ACT & ASSERT #
     check_execution(
         self, actor, [], arrangement_w_tcds(),
         Expectation(symbol_usages=asrt.matches_sequence([
             asrt_sym_ref.matches_reference_2(
                 symbol_reference.name,
                 data_restrictions_assertions.equals__w_str_rendering(
                     symbol_reference.value))
         ])))
Exemplo n.º 2
0
 def test_WHEN_parser_raises_exception_THEN_parse_SHOULD_raise_this_exception(
         self):
     # ARRANGE #
     parser_error = text_docs.single_pre_formatted_line_object('msg')
     actor = sut.ActorFromParts(ParserThatRaisesException(parser_error),
                                ValidatorConstructorThatRaises(),
                                ExecutorConstructorThatRaises())
     act_phase_instructions = []
     # ACT #
     with self.assertRaises(ParseException) as ex:
         executor = actor.parse(act_phase_instructions)
         # ASSERT #
         self.assertIs(parser_error, ex)
Exemplo n.º 3
0
    def test_full_sequence_of_steps(self):
        # ARRANGE #
        step_recorder = dict()
        actor = ParserThatExpectsSingleInstructionAndRecordsAndReturnsTheTextOfThatInstruction(
            step_recorder)

        actor = sut.ActorFromParts(
            actor, ValidatorConstructorThatRecordsStep(step_recorder),
            ExecutorConstructorThatRecordsStep(step_recorder))
        act_phase_instructions = [instr(['act phase source'])]
        arrangement = arrangement_w_tcds()
        expectation = simple_success()
        # ACT #
        check_execution(self, actor, act_phase_instructions, arrangement,
                        expectation)
        # ASSERT #
        expected_recordings = {
            phase_step.ACT__PARSE: 'act phase source',
            phase_step.ACT__VALIDATE_PRE_SDS: 'act phase source',
            phase_step.ACT__VALIDATE_POST_SETUP: 'act phase source',
            phase_step.ACT__PREPARE: 'act phase source',
            phase_step.ACT__EXECUTE: 'act phase source',
        }
        self.assertDictEqual(expected_recordings, step_recorder)
Exemplo n.º 4
0
    def test_hard_error_exception_from_executor_execute_SHOULD_be_handled(
            self):
        # ARRANGE #
        act_phase_instructions = []
        hard_error_message = 'the err msg'

        actor = sut.ActorFromParts(
            ParserWithConstantResult(SymbolUserWithConstantSymbolReferences(
                ())),
            sut.UnconditionallySuccessfulValidatorConstructor(),
            _ExecutorConstructorForConstant(
                ExecutorThat(execute_initial_action=do_raise(
                    HardErrorException(
                        asrt_text_doc.new_single_string_text_for_test(
                            hard_error_message))))),
        )

        arrangement = arrangement_w_tcds()
        expectation = Expectation.hard_error_from_execute(
            error_message=asrt_text_doc.
            is_single_pre_formatted_text_that_equals(hard_error_message))
        # ACT & ASSERT #
        check_execution(self, actor, act_phase_instructions, arrangement,
                        expectation)
Exemplo n.º 5
0
def actor() -> Actor:
    return parts.ActorFromParts(
        Parser(),
        _TheValidatorConstructor(),
        _TheExecutorConstructor(),
    )
Exemplo n.º 6
0
def actor(interpreter: CommandSdv) -> Actor:
    return parts.ActorFromParts(
        pa.Parser(interpreter),
        _TheValidatorConstructor(),
        _ExecutorConstructor(),
    )
Exemplo n.º 7
0
def actor() -> Actor:
    return parts.ActorFromParts(
        _Parser(),
        parts.UnconditionallySuccessfulValidatorConstructor(),
        _ExecutorConstructor(),
    )