예제 #1
0
    def test(self):
        # ARRANGE #
        const_pi = Paragraph([])
        cases = [
            NEA('empty sequence of paragraphs',
                expected=asrt.matches_sequence([]),
                actual=[]
                ),
            NEA('single paragraph',
                expected=asrt.matches_sequence([
                    asrt.is__any(const_pi)
                ]),
                actual=[const_pi]
                ),
        ]

        for case in cases:
            with self.subTest(case.name):
                # ACT #

                actual = sut.constant(case.actual).apply(CONSTRUCTION_ENVIRONMENT)

                # ASSERT #

                case.expected.apply_without_message(self, actual)
예제 #2
0
    def test_hierarchy_with_sub_sections(self):
        # ARRANGE #

        target_factory = TargetInfoFactoryTestImpl(['target_component'])
        expected_section_contents_object1 = doc.empty_section_contents()
        expected_section_contents_object2 = docs.section_contents(docs.paras('testing testing'))
        expected_root_initial_para = docs.para('root initial paras')
        expected_root_initial_paras = [expected_root_initial_para]

        root_header = StringText('root header')

        sub_section_header_1 = 'sub1'
        sub_section_header_2 = 'sub2'
        sub_section_local_target_1 = 'sub-target1'
        sub_section_local_target_2 = 'sub-target2'

        object_to_test = sut.hierarchy(
            root_header,
            paragraphs.constant(expected_root_initial_paras),
            [sut.child(sub_section_local_target_1,
                       sut.leaf(sub_section_header_1,
                                section_contents(expected_section_contents_object1))),
             sut.child(sub_section_local_target_2,
                       sut.leaf(sub_section_header_2,
                                section_contents(expected_section_contents_object2)))
             ])
        # EXPECTATION #
        expected_root_target_info = target_factory.root(root_header)

        sub1_target = target_factory.sub(sub_section_header_1, sub_section_local_target_1)
        sub2_target = target_factory.sub(sub_section_header_2, sub_section_local_target_2)
        target_info_node_assertion = equals_target_info_node(
            TargetInfoNode(expected_root_target_info,
                           [
                               target_info_leaf(sub1_target),
                               target_info_leaf(sub2_target),
                           ]),
            mk_equals_cross_ref_id=equals_custom_cross_ref_test_impl)

        section_assertion2 = section_matches(
            target=equals_custom_cross_ref_test_impl(expected_root_target_info.target),
            header=asrt_para.equals_text(expected_root_target_info.presentation_text),
            contents=section_contents_matches(
                initial_paragraphs=asrt.matches_sequence([asrt.Is(expected_root_initial_para)]),
                sections=asrt.matches_sequence([
                    section_matches(
                        target=equals_custom_cross_ref_test_impl(sub1_target.target),
                        header=asrt_para.equals_text(sub1_target.presentation_text),
                        contents=asrt.Is(expected_section_contents_object1)),
                    section_matches(
                        target=equals_custom_cross_ref_test_impl(sub2_target.target),
                        header=asrt_para.equals_text(sub2_target.presentation_text),
                        contents=asrt.Is(expected_section_contents_object2)),
                ])))
        # ACT & ASSERT #
        self._act_and_assert(object_to_test,
                             target_factory,
                             target_info_node_assertion,
                             section_assertion2)
예제 #3
0
    def test_hierarchy_with_sub_sections(self):
        # ARRANGE #

        target_factory = TargetInfoFactoryTestImpl(['target_component'])
        expected_section_contents_object1 = doc.empty_section_contents()
        expected_section_contents_object2 = docs.section_contents(docs.paras('testing testing'))
        expected_root_initial_para = docs.para('root initial paras')
        expected_root_initial_paras = [expected_root_initial_para]

        root_header = StringText('root header')

        sub_section_header_1 = 'sub1'
        sub_section_header_2 = 'sub2'
        sub_section_local_target_1 = 'sub-target1'
        sub_section_local_target_2 = 'sub-target2'

        object_to_test = sut.hierarchy(
            root_header,
            paragraphs.constant(expected_root_initial_paras),
            [sut.child(sub_section_local_target_1,
                       sut.leaf(sub_section_header_1,
                                section_contents(expected_section_contents_object1))),
             sut.child(sub_section_local_target_2,
                       sut.leaf(sub_section_header_2,
                                section_contents(expected_section_contents_object2)))
             ])
        # EXPECTATION #
        expected_root_target_info = target_factory.root(root_header)

        sub1_target = target_factory.sub(sub_section_header_1, sub_section_local_target_1)
        sub2_target = target_factory.sub(sub_section_header_2, sub_section_local_target_2)
        target_info_node_assertion = equals_target_info_node(
            TargetInfoNode(expected_root_target_info,
                           [
                               target_info_leaf(sub1_target),
                               target_info_leaf(sub2_target),
                           ]),
            mk_equals_cross_ref_id=equals_custom_cross_ref_test_impl)

        section_assertion2 = section_matches(
            target=equals_custom_cross_ref_test_impl(expected_root_target_info.target),
            header=asrt_para.equals_text(expected_root_target_info.presentation_text),
            contents=section_contents_matches(
                initial_paragraphs=asrt.matches_sequence([asrt.Is(expected_root_initial_para)]),
                sections=asrt.matches_sequence([
                    section_matches(
                        target=equals_custom_cross_ref_test_impl(sub1_target.target),
                        header=asrt_para.equals_text(sub1_target.presentation_text),
                        contents=asrt.Is(expected_section_contents_object1)),
                    section_matches(
                        target=equals_custom_cross_ref_test_impl(sub2_target.target),
                        header=asrt_para.equals_text(sub2_target.presentation_text),
                        contents=asrt.Is(expected_section_contents_object2)),
                ])))
        # ACT & ASSERT #
        self._act_and_assert(object_to_test,
                             target_factory,
                             target_info_node_assertion,
                             section_assertion2)
 def _instruction_groups(self, groups: Sequence[InstructionGroup]) -> List[SectionHierarchyGenerator]:
     return [
         h.child_hierarchy(group.identifier,
                           group.header,
                           paragraphs.constant(group.description_paragraphs),
                           self._instructions(group.instruction_documentations)
                           )
         for group in groups
     ]
 def hierarchy(self) -> SectionHierarchyGenerator:
     initial_paragraphs = paragraphs.constant(
         docs.paras(_INSTRUCTIONS_IN.format(
             section_concept=self.section_concept_name,
             section=self.section.name)
         ))
     return h.hierarchy(self.section.syntax_name_text,
                        initial_paragraphs,
                        self._instructions_layout(),
                        )
예제 #6
0
def root(header: str, setup: Setup) -> generator.SectionHierarchyGenerator:
    preamble_paragraphs = normalize_and_parse(PREAMBLE)

    def const_contents(header_: str, paragraphs: List[ParagraphItem]) -> generator.SectionHierarchyGenerator:
        return h.leaf(header_,
                      sections.constant_contents(section_contents(paragraphs)))

    return h.hierarchy(
        header,
        paragraphs.constant(preamble_paragraphs),
        [
            h.child('reporting',
                    const_contents('Reporting',
                                   TEXT_PARSER.fnap(REPORTING))

                    ),
            h.child('scenarios',
                    h.hierarchy(
                        'Scenarios',
                        children=[
                            h.child('complete-execution',
                                    const_contents('Complete execution',
                                                   _description_of_complete_execution(setup))

                                    ),
                            h.child('error-during-validation',
                                    const_contents('Error during validation',
                                                   _error_in_validation_before_execution())

                                    ),
                            h.child('error-during-execution',
                                    const_contents('Error during execution',
                                                   _interrupted_execution(setup))

                                    ),
                            h.child('other-errors',
                                    const_contents('Other errors',
                                                   _other_errors(setup))

                                    ),
                        ]
                    )),
            h.child('summary-of-exit-codes',
                    const_contents(ALL_EXIT_VALUES_SUMMARY_TABLE_HEADER,
                                   [all_exit_values_summary_table()]
                                   )

                    ),
        ]
    )
예제 #7
0
def root(header: str) -> generator.SectionHierarchyGenerator:
    preamble_paragraphs = TEXT_PARSER.fnap(PREAMBLE)

    def const_contents(
        header_: str, paragraphs_: List[ParagraphItem]
    ) -> generator.SectionHierarchyGenerator:
        return h.leaf(
            header_, sections.constant_contents(section_contents(paragraphs_)))

    return h.hierarchy(header, paragraphs.constant(preamble_paragraphs), [
        h.child('reporting',
                h.leaf('Reporting', _ReportingContentsConstructor())),
        h.child('scenarios', const_contents('Scenarios', _scenarios_list())),
    ])
예제 #8
0
    def test(self):
        # ARRANGE #
        const_pi_1 = Paragraph([])
        const_pi_2 = Paragraph([StringText('const pi 2')])
        const_pi_3 = Paragraph([StringText('const pi 3')])
        cases = [
            NEA('empty sequence of paragraphs',
                expected=asrt.matches_sequence([]),
                actual=[]
                ),
            NEA('single constructor',
                expected=asrt.matches_sequence([
                    asrt.is__any(const_pi_1)
                ]),
                actual=[sut.constant([const_pi_1])]
                ),
            NEA('multiple constructors',
                expected=asrt.matches_sequence([
                    asrt.is__any(const_pi_1),
                    asrt.is__any(const_pi_2),
                    asrt.is__any(const_pi_3),
                ]),
                actual=[sut.constant([const_pi_1,
                                      const_pi_2]),
                        sut.constant([const_pi_3])]
                ),
        ]

        for case in cases:
            with self.subTest(case.name):
                # ACT #

                actual = sut.sequence(case.actual).apply(CONSTRUCTION_ENVIRONMENT)

                # ASSERT #

                case.expected.apply_without_message(self, actual)
예제 #9
0
 def generator(self, header: str) -> SectionHierarchyGenerator:
     return h.hierarchy(header, paragraphs.constant(
         self._tp.fnap(_PRELUDE)
     ), [
         h.child('cases-and-sub-suites',
                 self._cases_and_sub_suites(CASES_AND_SUB_SUITES_HEADER)),
         h.child('common-test-case-contents',
                 self._common_tc_contents(COMMON_CASE_CONTENTS_HEADER)),
         h.child(
             'additional-test-case-conf',
             h.leaf(
                 ADDITIONAL_TEST_CASE_CONFIG_HEADER,
                 sections.constant_contents(
                     docs.section_contents(
                         self._tp.fnap(_ADDITIONAL_TEST_CASE_CONFIG))))),
     ])
예제 #10
0
 def generator(self, header: str) -> SectionHierarchyGenerator:
     return h.hierarchy(
         header,
         paragraphs.constant(self._tp.fnap(_PRELUDE)),
         [
             h.child('cases-and-sub-suites',
                     self._cases_and_sub_suites(CASES_AND_SUB_SUITES_HEADER)
                     ),
             h.child('common-test-case-contents',
                     self._common_tc_contents(COMMON_CASE_CONTENTS_HEADER)
                     ),
             h.child('additional-test-case-conf',
                     h.leaf(
                         ADDITIONAL_TEST_CASE_CONFIG_HEADER,
                         sections.constant_contents(
                             docs.section_contents(self._tp.fnap(_ADDITIONAL_TEST_CASE_CONFIG))
                         ))
                     ),
         ])
예제 #11
0
def root(header: str) -> generator.SectionHierarchyGenerator:
    preamble_paragraphs = TEXT_PARSER.fnap(PREAMBLE)

    def const_contents(header_: str, paragraphs_: List[ParagraphItem]) -> generator.SectionHierarchyGenerator:
        return h.leaf(header_,
                      sections.constant_contents(section_contents(paragraphs_)))

    return h.hierarchy(
        header,
        paragraphs.constant(preamble_paragraphs),
        [
            h.child('reporting',
                    h.leaf('Reporting',
                           _ReportingContentsConstructor())
                    ),
            h.child('scenarios',
                    const_contents('Scenarios',
                                   _scenarios_list())
                    ),
        ]
    )
예제 #12
0
def root(header: str) -> generator.SectionHierarchyGenerator:
    preamble_paragraphs = normalize_and_parse(PREAMBLE)

    def const_contents(
        header_: str, paragraphs: List[ParagraphItem]
    ) -> generator.SectionHierarchyGenerator:
        return h.leaf(header_,
                      sections.constant_contents(section_contents(paragraphs)))

    return h.hierarchy(header, paragraphs.constant(preamble_paragraphs), [
        h.child('reporting',
                const_contents('Reporting', TEXT_PARSER.fnap(REPORTING))),
        h.child(
            'scenarios',
            h.hierarchy(
                'Scenarios',
                children=[
                    h.child(
                        'complete-execution',
                        const_contents('Complete execution',
                                       _description_of_complete_execution())),
                    h.child(
                        'error-during-validation',
                        const_contents(
                            'Error during validation',
                            _error_in_validation_before_execution())),
                    h.child(
                        'error-during-execution',
                        const_contents('Error during execution',
                                       _interrupted_execution())),
                    h.child('other-errors',
                            const_contents('Other errors', _other_errors())),
                ])),
        h.child(
            'summary-of-exit-codes',
            const_contents(ALL_EXIT_VALUES_SUMMARY_TABLE_HEADER,
                           [all_exit_values_summary_table()])),
    ])
예제 #13
0
def root(header: str) -> generator.SectionHierarchyGenerator:
    tp = TextParser({

        'program_name': formatting.program_name(program_info.PROGRAM_NAME),
        'conf_param': formatting.concept_(concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO),

        'tcds_concept': formatting.concept_(concepts.TCDS_CONCEPT_INFO),
        'TCDS': concepts.TCDS_CONCEPT_INFO.acronym,

        'SDS': concepts.SDS_CONCEPT_INFO.acronym,
        'sds_concept': formatting.concept_(concepts.SDS_CONCEPT_INFO),
        'Sds_concept_header': concepts.SDS_CONCEPT_INFO.singular_name.capitalize(),
        'sds_single_line_description':
            concepts.SDS_CONCEPT_INFO.single_line_description_str.capitalize(),

        'HDS': concepts.HDS_CONCEPT_INFO.acronym,
        'hds_concept': formatting.concept_(concepts.HDS_CONCEPT_INFO),
        'Hds_concept_header': concepts.HDS_CONCEPT_INFO.singular_name.capitalize(),
        'hds_single_line_description':
            concepts.HDS_CONCEPT_INFO.single_line_description_str.capitalize(),

        'conf_phase': phase_names.CONFIGURATION,
        'act_phase': phase_names.ACT,

        'act_hds_conf_param': formatting.conf_param(test_case_file_structure.HDS_ACT_INFO.identifier),

        'path_type': types.PATH_TYPE_INFO.name,

        'symbol_concept': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO),
        'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME),

        'os_process': misc_texts.OS_PROCESS_NAME,
        'env_var': concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.name,
        'timeout': concepts.TIMEOUT_CONCEPT_INFO.name,
        'timeout_instruction': InstructionName(instruction_names.TIMEOUT_INSTRUCTION_NAME),
        'type': concepts.TYPE_CONCEPT_INFO.name,
        'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name,

        'relativity': formatting.concept(misc_texts.RELATIVITY.singular),
        'relativities': formatting.concept(misc_texts.RELATIVITY.plural),

        'cd': formatting.emphasis(instruction_names.CHANGE_DIR_INSTRUCTION_NAME),
        'env': formatting.emphasis(instruction_names.ENV_VAR_INSTRUCTION_NAME),
        'CD': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
    })

    def const_paragraphs_child(local_target_name: str,
                               header_: str,
                               paragraphs_: List[ParagraphItem]) -> generator.SectionHierarchyGenerator:
        return h.child(local_target_name,
                       h.leaf(header_,
                              sections.constant_contents(section_contents(paragraphs_)))
                       )

    return h.hierarchy(
        header,
        children=[
            h.child_hierarchy(
                'dir-structure',
                'Directory structure and Current directory',
                paragraphs.constant(tp.fnap(_DS_CD_PREAMBLE)),
                [
                    const_paragraphs_child(
                        'sds',
                        concepts.SDS_CONCEPT_INFO.singular_name.capitalize() +
                        ' and Current directory',
                        tp.fnap(_SDS_AND_CD)
                    ),
                    const_paragraphs_child(
                        'hds',
                        concepts.HDS_CONCEPT_INFO.singular_name.capitalize(),
                        tp.fnap(_HDS),
                    ),
                    const_paragraphs_child(
                        'file-ref',
                        'File references',
                        tp.fnap(_FILE_REFERENCES)
                    ),
                    h.leaf_not_in_toc(
                        see_also.SEE_ALSO_TITLE,
                        see_also.SeeAlsoSectionContentsConstructor(
                            see_also.items_of_targets(_dir_struct_see_also_targets())
                        )),
                ]
            ),
            h.child_hierarchy(
                'symbols',
                concepts.SYMBOL_CONCEPT_INFO.plural_name.capitalize(),
                paragraphs.constant(tp.fnap(_SYMBOLS)),
                [
                    h.leaf_not_in_toc(
                        see_also.SEE_ALSO_TITLE,
                        see_also.SeeAlsoSectionContentsConstructor(
                            see_also.items_of_targets(_symbols_see_also_targets())
                        ))
                ]
            ),
            h.child_hierarchy(
                'os-proc',
                tp.text(misc_texts.OS_PROCESS_ENVIRONMENT_SECTION_HEADER),
                paragraphs.constant(tp.fnap(_OS_PROC_INTRO)),
                [
                    const_paragraphs_child(
                        'cd',
                        'Current directory',
                        tp.fnap(_OS_PROC_CURRENT_DIRECTORY),
                    ),
                    const_paragraphs_child(
                        'env-vars',
                        tp.format('{env_var:s/u}'),
                        environment_variable.common_description(),
                    ),
                    const_paragraphs_child(
                        'timeout',
                        'Timeout',
                        tp.fnap(_OS_PROC_TIMEOUT),
                    ),
                    h.leaf_not_in_toc(
                        see_also.SEE_ALSO_TITLE,
                        see_also.SeeAlsoSectionContentsConstructor(
                            see_also.items_of_targets(_os_process_see_also_targets())
                        )
                    ),
                ],
            ),
        ]
    )
예제 #14
0
def root(header: str, test_case_help: TestCaseHelp) -> generator.SectionHierarchyGenerator:
    tp = TextParser({
        'default_suite_file_name': file_names.DEFAULT_SUITE_FILE,
        'act': phase_infos.ACT.name,
        'assert': phase_infos.ASSERT.name,
        'setup': phase_infos.SETUP.name,
        'action_to_check': concepts.ACTION_TO_CHECK_CONCEPT_INFO.name,
        'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name,
        'ATC': concepts.ACTION_TO_CHECK_CONCEPT_INFO.acronym,
        'actor': concepts.ACTOR_CONCEPT_INFO.name,
        'os_process': misc_texts.OS_PROCESS_NAME,
        'null_actor': actors.NULL_ACTOR.singular_name,
        'shell_command_marker': SHELL_COMMAND_MARKER,
        'shell_command': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND),
        'shell_command_line': formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND_LINE),
    })

    def const_paragraphs(header_: StrOrStringText,
                         initial_paragraphs: List[docs.ParagraphItem]) -> generator.SectionHierarchyGenerator:
        return h.leaf(header_,
                      sections.constant_contents(docs.section_contents(initial_paragraphs)))

    def phases_documentation() -> List[ParagraphItem]:
        return (tp.fnap(_PHASES_INTRO) +
                [sections_short_list(test_case_help.phase_helps_in_order_of_execution,
                                     phase_identifier.DEFAULT_PHASE.section_name,
                                     phase_names_plain.SECTION_CONCEPT_NAME)])

    act_contents = sections.contents(
        paragraphs.constant(tp.fnap(_ACT)),
        [
            _act_examples(tp),
            see_also.SeeAlsoSectionConstructor(
                see_also.items_of_targets(_act_see_also_targets())
            )
        ]
    )

    instructions_contents = sections.contents(
        paragraphs.constant(tp.fnap(_INSTRUCTIONS)),
        [
            see_also.SeeAlsoSectionConstructor(
                see_also.items_of_targets(_instructions_see_also_targets())
            )
        ]
    )

    return h.hierarchy(
        header,
        children=[
            h.child('phases',
                    const_paragraphs('Phases',
                                     phases_documentation())
                    ),
            h.child('act',
                    h.leaf(
                        tp.text('The {act} phase, {action_to_check:/q} and {actor:s/q}'),
                        act_contents
                    )
                    ),
            h.child('instructions',
                    h.leaf(tp.text('{instruction:s/u}'),
                           instructions_contents)
                    ),
            h.child('suites',
                    h.hierarchy(
                        'Relation to test suites',
                        children=[
                            h.child('suite-contents',
                                    const_paragraphs('Inclusion of phase contents from suites',
                                                     tp.fnap(_SUITE_CONTENTS_INCLUSION))
                                    ),
                            h.child('part-of-suite',
                                    const_paragraphs('Part of suite',
                                                     tp.fnap(_PART_OF_SUITE))
                                    ),
                            h.leaf_not_in_toc(
                                see_also.SEE_ALSO_TITLE,
                                see_also.SeeAlsoSectionContentsConstructor(
                                    see_also.items_of_targets(_suite_see_also_targets())
                                )
                            ),
                        ]),
                    ),
        ]
    )
예제 #15
0
def root(header: str, setup: Setup) -> generator.SectionHierarchyGenerator:
    tp = TextParser({
        'default_suite_file_name': file_names.DEFAULT_SUITE_FILE,
        'act': phase_infos.ACT.name,
        'action_to_check': concepts.ACTION_TO_CHECK_CONCEPT_INFO.name,
        'ATC': concepts.ACTION_TO_CHECK_CONCEPT_INFO.acronym,
        'actor': concepts.ACTOR_CONCEPT_INFO.name,
        'os_process': misc_texts.OS_PROCESS_NAME,
        'null_actor': actors.NULL_ACTOR.singular_name,
        'shell_command_marker': SHELL_COMMAND_MARKER,
    })

    def const_paragraphs(header_: StrOrStringText,
                         initial_paragraphs: List[docs.ParagraphItem]) -> generator.SectionHierarchyGenerator:
        return h.leaf(header_,
                      sections.constant_contents(docs.section_contents(initial_paragraphs)))

    def phases_documentation() -> List[ParagraphItem]:
        return (tp.fnap(_PHASES_INTRO) +
                [sections_short_list(setup.test_case_help.phase_helps_in_order_of_execution,
                                     phase_identifier.DEFAULT_PHASE.section_name,
                                     phase_names_plain.SECTION_CONCEPT_NAME)])

    act_contents = sections.contents(
        paragraphs.constant(tp.fnap(_ACT)),
        [
            _act_examples(tp),
            see_also.SeeAlsoSectionConstructor(
                see_also.items_of_targets(_act_see_also_targets())
            )
        ]
    )

    instructions_contents = sections.contents(
        paragraphs.constant(tp.fnap(_INSTRUCTIONS)),
        [
            see_also.SeeAlsoSectionConstructor(
                see_also.items_of_targets(_instructions_see_also_targets())
            )
        ]
    )

    return h.hierarchy(
        header,
        children=[
            h.child('phases',
                    const_paragraphs('Phases',
                                     phases_documentation())
                    ),
            h.child('act',
                    h.leaf(
                        tp.text('The {act} phase, {action_to_check:/q} and {actor:s/q}'),
                        act_contents
                    )
                    ),
            h.child('instructions',
                    h.leaf('Instructions',
                           instructions_contents)
                    ),
            h.child('suites',
                    h.hierarchy(
                        'Relation to test suites',
                        children=[
                            h.child('suite-contents',
                                    const_paragraphs('Inclusion of phase contents from suites',
                                                     tp.fnap(_SUITE_CONTENTS_INCLUSION))
                                    ),
                            h.child('part-of-suite',
                                    const_paragraphs('Part of suite',
                                                     tp.fnap(_PART_OF_SUITE))
                                    ),
                            h.with_not_in_toc(
                                h.leaf(
                                    see_also.SEE_ALSO_TITLE,
                                    see_also.SeeAlsoSectionContentsConstructor(
                                        see_also.items_of_targets(_suite_see_also_targets())
                                    )))
                            ,
                        ]),
                    ),
        ]
    )
예제 #16
0
 def paragraphs_of(template: str) -> paragraphs.ParagraphItemsConstructor:
     return paragraphs.constant(tp.fnap(template))
예제 #17
0
def root(header: str) -> generator.SectionHierarchyGenerator:
    tp = TextParser({

        'program_name': formatting.program_name(program_info.PROGRAM_NAME),
        'conf_param': formatting.concept_(concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO),

        'tcds_concept': formatting.concept_(concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO),
        'TCDS': concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO.acronym,

        'SDS': concepts.SANDBOX_CONCEPT_INFO.acronym,
        'sds_concept': formatting.concept_(concepts.SANDBOX_CONCEPT_INFO),
        'Sds_concept_header': concepts.SANDBOX_CONCEPT_INFO.singular_name.capitalize(),
        'sds_single_line_description':
            concepts.SANDBOX_CONCEPT_INFO.single_line_description_str.capitalize(),

        'HDS': concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.acronym,
        'hds_concept': formatting.concept_(concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO),
        'Hds_concept_header': concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.singular_name.capitalize(),
        'hds_single_line_description':
            concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.single_line_description_str.capitalize(),

        'conf_phase': phase_names.CONFIGURATION,
        'act_phase': phase_names.ACT,

        'act_home_conf_param': formatting.conf_param(test_case_file_structure.HDS_ACT_INFO.identifier),

        'data': type_system.DATA_TYPE_CATEGORY_NAME,
        'path_type': formatting.term(types.PATH_TYPE_INFO.singular_name),

        'symbol_concept': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO),
        'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME),

        'os_process': misc_texts.OS_PROCESS_NAME,
        'time_out_conf_param': formatting.conf_param_(conf_params.TIMEOUT_CONF_PARAM_INFO),

        'relativity': formatting.concept(misc_texts.RELATIVITY.singular),
        'relativities': formatting.concept(misc_texts.RELATIVITY.plural),

        'cd': formatting.emphasis(instruction_names.CHANGE_DIR_INSTRUCTION_NAME),
        'env': formatting.emphasis(instruction_names.ENV_VAR_INSTRUCTION_NAME),
        'CD': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
    })

    def const_paragraphs_child(local_target_name: str,
                               header_: str,
                               paragraphs_: List[ParagraphItem]) -> generator.SectionHierarchyGenerator:
        return h.child(local_target_name,
                       h.leaf(header_,
                              sections.constant_contents(section_contents(paragraphs_)))
                       )

    return h.hierarchy(
        header,
        children=[
            h.child_hierarchy(
                'dir-structure',
                'Directory structure and Current directory',
                paragraphs.constant(tp.fnap(_DS_CD_PREAMBLE)),
                [
                    const_paragraphs_child(
                        'sds',
                        concepts.SANDBOX_CONCEPT_INFO.singular_name.capitalize() +
                        ' and Current directory',
                        tp.fnap(_SDS_AND_CD)
                    ),
                    const_paragraphs_child(
                        'hds',
                        concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.singular_name.capitalize(),
                        tp.fnap(_HDS),
                    ),
                    const_paragraphs_child(
                        'file-ref',
                        'File references',
                        tp.fnap(_FILE_REFERENCES)
                    ),
                    h.child('see-also',
                            h.with_not_in_toc(
                                h.leaf(
                                    see_also.SEE_ALSO_TITLE,
                                    see_also.SeeAlsoSectionContentsConstructor(
                                        see_also.items_of_targets(_dir_struct_see_also_targets())
                                    )))
                            ),
                ]
            ),
            h.child_hierarchy(
                'symbols',
                concepts.SYMBOL_CONCEPT_INFO.plural_name.capitalize(),
                paragraphs.constant(tp.fnap(_SYMBOLS)),
                [
                    h.with_not_in_toc(
                        h.child_leaf(
                            'see-also',
                            see_also.SEE_ALSO_TITLE,
                            see_also.SeeAlsoSectionContentsConstructor(
                                see_also.items_of_targets(_symbols_see_also_targets())
                            ))
                    )
                ]
            ),
            h.child_hierarchy(
                'os-proc',
                tp.text('{os_process} environment'),
                paragraphs.constant(tp.fnap(_OS_PROC_INTRO)),
                [
                    const_paragraphs_child(
                        'cd',
                        'Current directory',
                        tp.fnap(_OS_PROC_CURRENT_DIRECTORY),
                    ),
                    const_paragraphs_child(
                        'env-vars',
                        'Environment variables',
                        tp.fnap(_OS_PROC_ENVIRONMENT_VARIABLES),
                    ),
                    const_paragraphs_child(
                        'timeout',
                        'Timeout',
                        tp.fnap(_OS_PROC_TIMEOUT),
                    ),
                    h.with_not_in_toc(
                        h.child_leaf(
                            'see-also',
                            see_also.SEE_ALSO_TITLE,
                            see_also.SeeAlsoSectionContentsConstructor(
                                see_also.items_of_targets(_os_process_see_also_targets())
                            )))
                    ,
                ],
            ),
        ]
    )