Пример #1
0
def hierarchy(header: str,
              suite_help: TestSuiteHelp) -> SectionHierarchyGenerator:
    tp = TextParser({
        'program_name': formatting.program_name(program_info.PROGRAM_NAME),
        'executable_name': program_info.PROGRAM_NAME,
        'suite_program_mode': SUITE_COMMAND,
        'reporter_concept': formatting.concept_(concepts.SUITE_REPORTER_CONCEPT_INFO),
        'cases': section_names.CASES,
        'suites': section_names.SUITES,
        'ALL_PASS': exit_values.ALL_PASS.exit_identifier,
        'generic_section': SectionName('NAME'),
    })

    def section_of_parsed(contents: str) -> SectionContentsConstructor:
        return sections.constant_contents(
            docs.section_contents(tp.fnap(contents))
        )

    return h.hierarchy(
        header,
        children=[
            h.child('introduction',
                    h.leaf('Introduction',
                           section_of_parsed(_INTRODUCTION))
                    ),
            h.child('structure',
                    structure.root('Structure', suite_help)
                    ),
            h.child('file-syntax',
                    h.leaf('File syntax',
                           section_of_parsed(_FILE_SYNTAX))
                    ),
            h.child('outcome',
                    outcome.root('Outcome')),
        ])
Пример #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 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_)))
                    )
Пример #4
0
 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_)))
                    )
Пример #5
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))))),
     ])
Пример #6
0
    def _section_setup_for_entity(names: EntityTypeNames) -> SectionHierarchyGenerator:
        return h.child(
            names.identifier,
            application_help.entity_type_conf_for(names.identifier).get_hierarchy_generator(
                names.name.plural.capitalize()),

        )
Пример #7
0
    def test_with_fixed_root_target(self):
        # ARRANGE #

        root_header = StringText('root header')
        sub_header = StringText('sub header')
        sub_local_target_name = 'should not be used'

        fixed_target = CustomCrossReferenceTargetTestImpl('the fixed root target')

        default_target = CustomCrossReferenceTargetTestImpl('default target component')

        target_factory = ConstantTargetInfoFactoryTestImpl(default_target)

        unadjusted_object = sut.hierarchy(root_header,
                                          paragraphs.empty(),
                                          [sut.child(sub_local_target_name,
                                                     sut.leaf(sub_header.value,
                                                              section_contents(doc.empty_section_contents())))
                                           ]
                                          )
        adjusted_object = sut.with_fixed_root_target(fixed_target,
                                                     unadjusted_object)

        # EXPECTATION #

        expected_root_target_info = TargetInfo(root_header,
                                               fixed_target)

        expected_sub_target_info = TargetInfo(sub_header,
                                              default_target)

        target_info_node_assertion = equals_target_info_node(
            TargetInfoNode(expected_root_target_info,
                           [target_info_leaf(expected_sub_target_info)]),
            mk_equals_cross_ref_id=equals_custom_cross_ref_test_impl)

        section_assertion = section_matches(
            target=equals_custom_cross_ref_test_impl(fixed_target),
            header=asrt_para.equals_text(expected_root_target_info.presentation_text),
            contents=section_contents_matches(
                initial_paragraphs=asrt.is_empty_sequence,
                sections=asrt.matches_sequence([
                    section_matches(
                        target=equals_custom_cross_ref_test_impl(default_target),
                        header=asrt_para.equals_text(sub_header),
                        contents=section_contents_matches(
                            initial_paragraphs=asrt.is_empty_sequence,
                            sections=asrt.is_empty_sequence
                        )
                    )
                ])
            ))

        # ACT & ASSERT #

        self._act_and_assert(adjusted_object,
                             target_factory,
                             target_info_node_assertion,
                             section_assertion)
Пример #8
0
    def test_with_fixed_root_target(self):
        # ARRANGE #

        root_header = StringText('root header')
        sub_header = StringText('sub header')
        sub_local_target_name = 'should not be used'

        fixed_target = CustomCrossReferenceTargetTestImpl('the fixed root target')

        default_target = CustomCrossReferenceTargetTestImpl('default target component')

        target_factory = ConstantTargetInfoFactoryTestImpl(default_target)

        unadjusted_object = sut.hierarchy(root_header,
                                          paragraphs.empty(),
                                          [sut.child(sub_local_target_name,
                                                     sut.leaf(sub_header.value,
                                                              section_contents(doc.empty_section_contents())))
                                           ]
                                          )
        adjusted_object = sut.with_fixed_root_target(fixed_target,
                                                     unadjusted_object)

        # EXPECTATION #

        expected_root_target_info = TargetInfo(root_header,
                                               fixed_target)

        expected_sub_target_info = TargetInfo(sub_header,
                                              default_target)

        target_info_node_assertion = equals_target_info_node(
            TargetInfoNode(expected_root_target_info,
                           [target_info_leaf(expected_sub_target_info)]),
            mk_equals_cross_ref_id=equals_custom_cross_ref_test_impl)

        section_assertion = section_matches(
            target=equals_custom_cross_ref_test_impl(fixed_target),
            header=asrt_para.equals_text(expected_root_target_info.presentation_text),
            contents=section_contents_matches(
                initial_paragraphs=asrt.is_empty_sequence,
                sections=asrt.matches_sequence([
                    section_matches(
                        target=equals_custom_cross_ref_test_impl(default_target),
                        header=asrt_para.equals_text(sub_header),
                        contents=section_contents_matches(
                            initial_paragraphs=asrt.is_empty_sequence,
                            sections=asrt.is_empty_sequence
                        )
                    )
                ])
            ))

        # ACT & ASSERT #

        self._act_and_assert(adjusted_object,
                             target_factory,
                             target_info_node_assertion,
                             section_assertion)
Пример #9
0
 def _section_setup_for_entity(
         names: EntityTypeNames) -> SectionHierarchyGenerator:
     return h.child(
         names.identifier,
         application_help.entity_type_conf_for(
             names.identifier).get_hierarchy_generator(
                 names.name.plural.capitalize()),
     )
Пример #10
0
def _case_and_suite_sections(
        application_help: ApplicationHelp) -> List[SectionHierarchyGenerator]:
    return [
        h.child(
            'test-case',
            test_case.hierarchy(
                _TEST_CASES_HEADER, application_help.test_case_help,
                application_help.entity_type_conf_for(
                    all_entity_types.DIRECTIVE_ENTITY_TYPE_NAMES.identifier))),
        h.child(
            'test-suite',
            test_suite.hierarchy(
                _TEST_SUITES_HEADER, application_help.test_suite_help,
                application_help.entity_type_conf_for(
                    all_entity_types.SUITE_REPORTER_ENTITY_TYPE_NAMES.
                    identifier))),
    ]
Пример #11
0
def _cli_syntax_sections(
        local_target_name: str) -> List[SectionHierarchyGenerator]:
    return [
        h.child(
            local_target_name,
            h.hierarchy('Command line syntax',
                        children=[
                            h.child('test-case',
                                    case_cli_syntax.root(_TEST_CASES_HEADER)),
                            h.child(
                                'test-suite',
                                suite_cli_syntax.root(_TEST_SUITES_HEADER)),
                            h.child('symbol',
                                    symbol_cli_syntax.root(_SYMBOL_HEADER)),
                            h.child('help', help.root('Help System')),
                        ]))
    ]
Пример #12
0
 def section_hierarchy_node(partition: EntitiesPartition) -> SectionHierarchyGenerator:
     return h.child(partition.partition_names_setup.local_target_name,
                    entities_list_renderer.entity_list_hierarchy(
                        self.entity_type_identifier,
                        self.entity_2_article_contents_renderer,
                        partition.partition_names_setup.header,
                        partition.entity_doc_list,
                    ))
Пример #13
0
def _case_and_suite_sections(application_help: ApplicationHelp) -> List[SectionHierarchyGenerator]:
    return [
        h.child(
            'test-case',
            test_case.hierarchy(_TEST_CASES_HEADER,
                                application_help.test_case_help,
                                application_help.entity_type_conf_for(
                                    all_entity_types.DIRECTIVE_ENTITY_TYPE_NAMES.identifier)
                                )
        ),
        h.child(
            'test-suite',
            test_suite.hierarchy(_TEST_SUITES_HEADER,
                                 application_help.test_suite_help,
                                 application_help.entity_type_conf_for(
                                     all_entity_types.SUITE_REPORTER_ENTITY_TYPE_NAMES.identifier))
        ),
    ]
Пример #14
0
 def section_hierarchy_node(
         partition: EntitiesPartition) -> SectionHierarchyGenerator:
     return h.child(
         partition.partition_names_setup.local_target_name,
         entities_list_renderer.entity_list_hierarchy(
             self.entity_type_identifier,
             self.entity_2_article_contents_renderer,
             partition.partition_names_setup.header,
             partition.entity_doc_list,
         ))
Пример #15
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))
                         ))
                     ),
         ])
Пример #16
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())
                    ),
        ]
    )
Пример #17
0
def _cli_syntax_sections(local_target_name: str) -> List[SectionHierarchyGenerator]:
    return [
        h.child(
            local_target_name,
            h.hierarchy('Command line syntax',
                        children=[
                            h.child('test-case',
                                    case_cli_syntax.root(_TEST_CASES_HEADER)
                                    ),
                            h.child('test-suite',
                                    suite_cli_syntax.root(_TEST_SUITES_HEADER)
                                    ),
                            h.child('symbol',
                                    symbol_cli_syntax.root(_SYMBOL_HEADER)
                                    ),
                            h.child('help',
                                    help.root('Getting Help')
                                    ),
                        ]
                        )
        )
    ]
 def instructions_per_section(self,
                              header: str,
                              ) -> SectionHierarchyGenerator:
     return h.hierarchy(header,
                        paragraphs.empty(),
                        [
                            h.child(section.name.plain,
                                    _InstructionsInSection.hierarchy_for(self._section_concept_name,
                                                                         section),
                                    )
                            for section in self._sections
                            if section.has_instructions
                        ])
Пример #19
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()]
                                   )

                    ),
        ]
    )
 def custom_sections_list(self,
                          header: str,
                          sections: Sequence[SectionDocumentation]) -> SectionHierarchyGenerator:
     return h.hierarchy(
         header,
         paragraphs.empty(),
         [
             h.child(section.name.plain,
                     h.with_fixed_root_target(
                         section.section_info.cross_reference_target,
                         h.leaf_article(
                             section.syntax_name_text,
                             self._article_constructor_for_section(section),
                             tags={std_tags.SECTION},
                         )
                     ),
                     )
             for section in sections
         ]
     )
Пример #21
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()])),
    ])
Пример #22
0
def root(header: str,
         test_case_help: TestCaseHelp) -> SectionHierarchyGenerator:
    return h.hierarchy(header,
                       children=[
                           h.child(
                               'introduction',
                               h.leaf('Introduction', intro.Documentation())),
                           h.child('structure',
                                   structure.root('Structure',
                                                  test_case_help)),
                           h.child('exe-env',
                                   env_doc.root('Execution environment')),
                           h.child('file-syntax',
                                   file_syntax.root('File syntax')),
                           h.child(
                               'processing',
                               h.leaf('Processing steps',
                                      processing.ContentsConstructor())),
                           h.child('outcome', outcome.root('Outcome')),
                       ])
Пример #23
0
def hierarchy(header: str,
              test_suite_help: TestSuiteHelp,
              suite_reporter_conf: EntityTypeConfiguration,
              ) -> generator.SectionHierarchyGenerator:
    sections_helper = GeneratorsForSectionDocument(SECTION_CONCEPT_NAME,
                                                   test_suite_help.section_helps,
                                                   TestSuiteSectionDocumentationConstructor)
    return h.hierarchy(
        header,
        children=[
            h.child('spec',
                    h.with_fixed_root_target(
                        PredefinedHelpContentsPartReference(HelpPredefinedContentsPart.TEST_SUITE_SPEC),
                        main.hierarchy(misc_texts.TEST_SUITE_SPEC_TITLE,
                                       test_suite_help)
                    )),
            h.child('sections',
                    h.hierarchy(
                        'Sections',
                        children=[
                            h.child('cases-and-sub-suites',
                                    sections_helper.custom_sections_list(
                                        test_suite_structure.CASES_AND_SUB_SUITES_HEADER,
                                        test_suite_help.test_cases_and_sub_suites_sections,
                                    )),
                            h.child('common-case-contents',
                                    sections_helper.custom_sections_list(
                                        test_suite_structure.COMMON_CASE_CONTENTS_AND_CONFIG_HEADER,
                                        test_suite_help.test_case_phase_sections,
                                    )),
                        ])
                    ),
            h.child('reporters',
                    suite_reporter_conf.get_hierarchy_generator(
                        SUITE_REPORTER_ENTITY_TYPE_NAMES.name.plural.capitalize())
                    ),
            h.child('instructions',
                    sections_helper.instructions_per_section('Instructions per section')
                    ),
        ]
    )
Пример #24
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())
                            )))
                    ,
                ],
            ),
        ]
    )
Пример #25
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())
                                )
                            ),
                        ]),
                    ),
        ]
    )
Пример #26
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())
                                    )))
                            ,
                        ]),
                    ),
        ]
    )