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 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')), ])
def entity_list_hierarchy(entity_type_identifier: str, mk_article_constructor: Callable[[EntityDocumentation], ArticleContentsConstructor], header: str, entities: List[EntityDocumentation] ) -> SectionHierarchyGenerator: def entity_node(entity: EntityDocumentation) -> SectionHierarchyGenerator: additional_tags = { std_tags.ENTITY, entity_type_identifier, } return h.with_fixed_root_target( entity.cross_reference_target(), h.leaf_article( entity.singular_name_text, mk_article_constructor(entity), additional_tags) ) return h.hierarchy( header, paragraphs.empty(), [ entity_node(entity) for entity in sorted_entity_list(entities) ] )
def hierarchy( header: str, test_case_help: TestCaseHelp, directive_conf: EntityTypeConfiguration, ) -> generator.SectionHierarchyGenerator: sections_helper = GeneratorsForSectionDocument( SECTION_CONCEPT_NAME, test_case_help.phase_helps_in_order_of_execution, TestCasePhaseDocumentationConstructor) return h.hierarchy( header, children=[ h.child( 'spec', h.with_fixed_root_target( PredefinedHelpContentsPartReference( HelpPredefinedContentsPart.TEST_CASE_SPEC), test_case_specification_rendering.root( misc_texts.TEST_CASE_SPEC_TITLE, test_case_help))), h.child('phases', sections_helper.all_sections_list('Phases')), h.child( 'directives', directive_conf.get_hierarchy_generator( DIRECTIVE_ENTITY_TYPE_NAMES.name.plural.capitalize())), h.child( 'instructions', sections_helper.instructions_per_section( 'Instructions per phase')), ])
def root(header: str) -> generator.SectionHierarchyGenerator: tp = _text_parser() def paragraphs_of(template: str) -> paragraphs.ParagraphItemsConstructor: return paragraphs.constant(tp.fnap(template)) def initial_paragraphs_of( template: str) -> sections.SectionContentsConstructor: return sections.contents(paragraphs_of(template)) file_inclusion_doc = sections.contents(paragraphs_of(FILE_INCLUSION_DOC), [ see_also.SeeAlsoSectionConstructor( see_also.items_of_targets(_FILE_INCLUSION_SEE_ALSO_TARGETS)) ]) return h.hierarchy( header, initial_paragraphs=paragraphs_of(_INTRO), children=[ h.child_leaf('phases', 'Phases', initial_paragraphs_of(PHASES_DOC)), h.child_leaf('phase-contents', 'Phase contents', initial_paragraphs_of(PHASES_CONTENTS_DOC)), h.child_hierarchy( 'instructions', 'Instructions', paragraphs_of(INSTRUCTIONS_DOC), [ h.child_leaf( 'description', defs.INSTRUCTION_DESCRIPTION.plural.capitalize(), initial_paragraphs_of(INSTRUCTIONS_DESCRIPTION_DOC)) ]), h.child_leaf('file-inclusion', 'File inclusion', file_inclusion_doc), h.child_leaf('com-empty', 'Comments and empty lines', initial_paragraphs_of(OTHER_DOC)), ])
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')), ])
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 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)
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)
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 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(), )
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') ), ] )
def _generator(application_help: ApplicationHelp) -> SectionHierarchyGenerator: return h.hierarchy( page_setup.PAGE_TITLE, children=( _case_and_suite_sections(application_help) + _entity_sections( application_help, entity_types_to_exclude=[ all_entity_types.SUITE_REPORTER_ENTITY_TYPE_NAMES. identifier, all_entity_types.DIRECTIVE_ENTITY_TYPE_NAMES.identifier ]) + _cli_syntax_sections('cli-syntax')), )
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 ])
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()])), ])
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())), ])
def _generator(application_help: ApplicationHelp) -> SectionHierarchyGenerator: return h.hierarchy( page_setup.PAGE_TITLE, children=( _case_and_suite_sections(application_help) + _entity_sections(application_help, entity_types_to_exclude=[ all_entity_types.SUITE_REPORTER_ENTITY_TYPE_NAMES.identifier, all_entity_types.DIRECTIVE_ENTITY_TYPE_NAMES.identifier]) + _cli_syntax_sections('cli-syntax') ), )
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))))), ])
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')), ])) ]
def entity_list_hierarchy( entity_type_identifier: str, mk_article_constructor: Callable[[EntityDocumentation], ArticleContentsConstructor], header: str, entities: List[EntityDocumentation]) -> SectionHierarchyGenerator: def entity_node(entity: EntityDocumentation) -> SectionHierarchyGenerator: additional_tags = { std_tags.ENTITY, entity_type_identifier, } return h.with_fixed_root_target( entity.cross_reference_target(), h.leaf_article(entity.singular_name_text, mk_article_constructor(entity), additional_tags)) return h.hierarchy( header, paragraphs.empty(), [entity_node(entity) for entity in sorted_entity_list(entities)])
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)) )) ), ])
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')), ])
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 ] )
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()) ), ] )
def get_hierarchy_generator( self, header: str, all_entity_doc_list: List[EntityDocumentation] ) -> generator.SectionHierarchyGenerator: 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, )) partitions = partition_entities(self.partition_setup_list, all_entity_doc_list) return h.hierarchy(docs.string_text(header), children=[ section_hierarchy_node(partition) for partition in partitions ])
def get_hierarchy_generator(self, header: str, all_entity_doc_list: List[EntityDocumentation] ) -> generator.SectionHierarchyGenerator: 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, )) partitions = partition_entities(self.partition_setup_list, all_entity_doc_list) return h.hierarchy( docs.string_text(header), children=[ section_hierarchy_node(partition) for partition in partitions ] )
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 test_hierarchy_without_sub_sections(self): # ARRANGE # target_factory = TargetInfoFactoryTestImpl(['target_component']) root_header_text = StringText('root header') object_to_test = sut.hierarchy(root_header_text, paragraphs.empty(), []) # EXPECTATION # expected_target_info = target_factory.root(root_header_text) target_info_node_assertion = equals_target_info_node( target_info_leaf(expected_target_info), mk_equals_cross_ref_id=equals_custom_cross_ref_test_impl) section_assertion = section_matches( target=equals_custom_cross_ref_test_impl(expected_target_info.target), header=asrt_para.equals_text(expected_target_info.presentation_text), contents=asrt.sub_component('is_empty', doc.SectionContents.is_empty.fget, asrt.is_true)) # ACT & ASSERT # self._act_and_assert(object_to_test, target_factory, target_info_node_assertion, section_assertion)
def test_hierarchy_without_sub_sections(self): # ARRANGE # target_factory = TargetInfoFactoryTestImpl(['target_component']) root_header_text = StringText('root header') object_to_test = sut.hierarchy(root_header_text, paragraphs.empty(), []) # EXPECTATION # expected_target_info = target_factory.root(root_header_text) target_info_node_assertion = equals_target_info_node( target_info_leaf(expected_target_info), mk_equals_cross_ref_id=equals_custom_cross_ref_test_impl) section_assertion = section_matches( target=equals_custom_cross_ref_test_impl(expected_target_info.target), header=asrt_para.equals_text(expected_target_info.presentation_text), contents=asrt.sub_component('is_empty', doc.SectionContents.is_empty.fget, asrt.is_true)) # ACT & ASSERT # self._act_and_assert(object_to_test, target_factory, target_info_node_assertion, section_assertion)
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()) ))) , ], ), ] )
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()) ) ), ], ), ] )
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()) ) ), ]), ), ] )
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()) ))) , ]), ), ] )