Example #1
0
 def test_unknown_phase(self):
     application_help = application_help_for(
         [section_documentation('phase', ['instruction-name'])])
     with self.assertRaises(HelpError):
         sut.parse(
             application_help,
             arguments_for.case_instructions_in_phase('non-existing-phase'))
Example #2
0
 def test_program_help(self):
     actual = sut.parse(application_help_for([]), [])
     self.assertIsInstance(actual, MainProgramHelpRequest,
                           'Expecting settings for MainProgram')
     assert isinstance(actual, MainProgramHelpRequest)
     self.assertIs(MainProgramHelpItem.PROGRAM, actual.item,
                   'Expects program help')
Example #3
0
 def test_unknown_section(self):
     application_help = application_help_for(
         [],
         suite_sections=[SectionDocumentationForSectionWithoutInstructionsTestImpl('section A')])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.suite_section_for_name('unknown section'))
Example #4
0
 def test_help_help(self):
     actual = sut.parse(application_help_for([]), [clo.HELP])
     self.assertIsInstance(actual, MainProgramHelpRequest,
                           'Expecting settings for MainProgram')
     assert isinstance(actual, MainProgramHelpRequest)
     self.assertIs(MainProgramHelpItem.HELP, actual.item,
                   'Expects MainProgram help for help')
Example #5
0
 def test_unknown_phase(self):
     application_help = application_help_for([
         section_documentation('phase', ['instruction-name'])
     ])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.case_instructions_in_phase('non-existing-phase'))
Example #6
0
 def test_unknown_instruction(self):
     instructions = ['known-instruction']
     application_help = application_help_for(
         [section_documentation('phase', instructions)])
     with self.assertRaises(HelpError):
         sut.parse(
             application_help,
             arguments_for.case_instruction_search('unknown-instruction'))
Example #7
0
 def test_instruction_set(self):
     actual = sut.parse(application_help_for([]),
                        arguments_for.case_instructions())
     self.assertIsInstance(actual, TestCaseHelpRequest,
                           'Expecting settings for Test Case')
     assert isinstance(actual, TestCaseHelpRequest)
     self.assertIs(TestCaseHelpItem.INSTRUCTION_SET, actual.item,
                   'Item should denote help for Instruction Set')
Example #8
0
 def test_cli_syntax(self):
     actual = sut.parse(application_help_for([]),
                        arguments_for.suite_cli_syntax())
     self.assertIsInstance(actual, TestSuiteHelpRequest,
                           'Expecting settings for test-suite')
     assert isinstance(actual, TestSuiteHelpRequest)
     self.assertIs(TestSuiteHelpItem.CLI_SYNTAX, actual.item,
                   'Item should denote help for test-suite overview')
Example #9
0
 def test_overview(self):
     actual = sut.parse(application_help_for([]),
                        arguments_for.suite_specification())
     self.assertIsInstance(actual, TestSuiteHelpRequest,
                           'Expecting settings for test-suite')
     assert isinstance(actual, TestSuiteHelpRequest)
     self.assertIs(TestSuiteHelpItem.SPECIFICATION, actual.item,
                   'Item should denote help for test-suite overview')
Example #10
0
 def test_existing_phase_without_instructions(self):
     phase_name = 'the phase name'
     application_help = application_help_for([
         SectionDocumentationForSectionWithoutInstructionsTestImpl(phase_name)
     ])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.case_instructions_in_phase(phase_name))
Example #11
0
 def test_unknown_instruction(self):
     application_help = application_help_for([
         section_documentation('phase-1', ['instruction']),
         section_documentation('empty-phase', []),
     ])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.case_instruction_in_phase('empty-phase', 'instruction'))
Example #12
0
 def test_existing_phase_without_instructions(self):
     phase_name = 'the phase name'
     application_help = application_help_for([
         SectionDocumentationForSectionWithoutInstructionsTestImpl(
             phase_name)
     ])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.case_instructions_in_phase(phase_name))
Example #13
0
 def test_program_help(self):
     actual = sut.parse(application_help_for([]),
                        [])
     self.assertIsInstance(actual,
                           MainProgramHelpRequest,
                           'Expecting settings for MainProgram')
     assert isinstance(actual, MainProgramHelpRequest)
     self.assertIs(MainProgramHelpItem.PROGRAM,
                   actual.item,
                   'Expects program help')
Example #14
0
 def test_instruction_set(self):
     actual = sut.parse(application_help_for([]),
                        arguments_for.case_instructions())
     self.assertIsInstance(actual, TestCaseHelpRequest,
                           'Expecting settings for Test Case')
     assert isinstance(actual, TestCaseHelpRequest)
     self.assertIs(
         TestCaseHelpItem.INSTRUCTION_SET,
         actual.item,
         'Item should denote help for Instruction Set')
Example #15
0
 def test_help_help(self):
     actual = sut.parse(application_help_for([]),
                        [clo.HELP])
     self.assertIsInstance(actual,
                           MainProgramHelpRequest,
                           'Expecting settings for MainProgram')
     assert isinstance(actual, MainProgramHelpRequest)
     self.assertIs(MainProgramHelpItem.HELP,
                   actual.item,
                   'Expects MainProgram help for help')
Example #16
0
 def test_unknown_instruction(self):
     application_help = application_help_for([
         section_documentation('phase-1', ['instruction']),
         section_documentation('empty-phase', []),
     ])
     with self.assertRaises(HelpError):
         sut.parse(
             application_help,
             arguments_for.case_instruction_in_phase(
                 'empty-phase', 'instruction'))
Example #17
0
 def test_unknown_section(self):
     application_help = application_help_for(
         [],
         suite_sections=[
             SectionDocumentationForSectionWithoutInstructionsTestImpl(
                 'section A')
         ])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.suite_section_for_name('unknown section'))
Example #18
0
 def test_overview(self):
     actual = sut.parse(application_help_for([]),
                        arguments_for.suite_specification())
     self.assertIsInstance(actual,
                           TestSuiteHelpRequest,
                           'Expecting settings for test-suite')
     assert isinstance(actual,
                       TestSuiteHelpRequest)
     self.assertIs(TestSuiteHelpItem.SPECIFICATION,
                   actual.item,
                   'Item should denote help for test-suite overview')
Example #19
0
 def test_cli_syntax(self):
     actual = sut.parse(application_help_for([]),
                        arguments_for.suite_cli_syntax())
     self.assertIsInstance(actual,
                           TestSuiteHelpRequest,
                           'Expecting settings for test-suite')
     assert isinstance(actual,
                       TestSuiteHelpRequest)
     self.assertIs(TestSuiteHelpItem.CLI_SYNTAX,
                   actual.item,
                   'Item should denote help for test-suite overview')
Example #20
0
 def test_instruction_in_single_phase(self):
     application_help = application_help_for([section_documentation('phase-a', ['a-instruction']),
                                              section_documentation('phase-with-target', ['target-instruction'])])
     actual = sut.parse(application_help, arguments_for.case_instruction_search('target-instruction'))
     actual = self._assert_is_valid_instruction_list_settings('target-instruction',
                                                              actual)
     self.assertEqual(1,
                      len(actual.data),
                      'One instruction is expected to be found')
     self.assertEqual('phase-with-target',
                      actual.data[0][0].plain,
                      'The instruction is expected to be found in the %s phase.' % 'phase-with-target')
Example #21
0
 def test_single_instruction_for_phases_with_instructions(self):
     phase_name = 'the phase name'
     instructions = [phase_name, 'name-that-is-not-the-name-of-a-phase']
     application_help = application_help_for([
         section_documentation(phase_name, instructions),
         section_documentation('other phase than ' + phase_name, instructions)
     ])
     self._assert_is_existing_instruction_in_phase(application_help,
                                                   phase_name,
                                                   'name-that-is-not-the-name-of-a-phase')
     self._assert_is_existing_instruction_in_phase(application_help,
                                                   phase_name,
                                                   phase_name)
Example #22
0
 def test_single_instruction_for_phases_with_instructions(self):
     phase_name = 'the phase name'
     instructions = [phase_name, 'name-that-is-not-the-name-of-a-phase']
     application_help = application_help_for([
         section_documentation(phase_name, instructions),
         section_documentation('other phase than ' + phase_name,
                               instructions)
     ])
     self._assert_is_existing_instruction_in_phase(
         application_help, phase_name,
         'name-that-is-not-the-name-of-a-phase')
     self._assert_is_existing_instruction_in_phase(application_help,
                                                   phase_name, phase_name)
Example #23
0
 def application_help_for_list_of_entities(
         self, entities: list) -> ApplicationHelp:
     return application_help_for(
         [],
         entity_name_2_entity_configuration={
             self.entity_type_name:
             EntityTypeConfiguration(
                 EntityTypeHelp(ACTOR_ENTITY_TYPE_NAMES, entities),
                 IndividualActorConstructor,
                 FlatListConstructorWithSingleLineDescriptionGetter(),
                 FlatEntityListHierarchyGeneratorGetter(
                     self.entity_type_name, IndividualActorConstructor),
             )
         })
Example #24
0
    def application_help_for_list_of_entities(self, entities: list) -> ApplicationHelp:
        return application_help_for([],
                                    entity_name_2_entity_configuration={
                                        self.entity_type_name:
                                            EntityTypeConfiguration(
                                                EntityTypeHelp(ACTOR_ENTITY_TYPE_NAMES,
                                                               entities),
                                                IndividualActorConstructor,
                                                FlatListConstructorWithSingleLineDescriptionGetter(),
                                                FlatEntityListHierarchyGeneratorGetter(
                                                    self.entity_type_name,
                                                    IndividualActorConstructor),

                                            )
                                    })
Example #25
0
 def test_known_section(self):
     actual = sut.parse(
         application_help_for(
             [],
             suite_sections=[
                 SectionDocumentationForSectionWithoutInstructionsTestImpl(
                     'section A'),
                 SectionDocumentationForSectionWithoutInstructionsTestImpl(
                     'section B')
             ]), arguments_for.suite_section_for_name('section A'))
     self.assertIsInstance(actual, TestSuiteHelpRequest,
                           'Expecting help for Suite Section')
     assert isinstance(actual, TestSuiteHelpRequest)
     self.assertIs(TestSuiteHelpItem.SECTION, actual.item,
                   'Item should denote help for a Section')
     self.assertIsInstance(actual.data, SectionDocumentation)
Example #26
0
 def test_instruction_in_single_phase(self):
     application_help = application_help_for([
         section_documentation('phase-a', ['a-instruction']),
         section_documentation('phase-with-target', ['target-instruction'])
     ])
     actual = sut.parse(
         application_help,
         arguments_for.case_instruction_search('target-instruction'))
     actual = self._assert_is_valid_instruction_list_settings(
         'target-instruction', actual)
     self.assertEqual(1, len(actual.data),
                      'One instruction is expected to be found')
     self.assertEqual(
         'phase-with-target', actual.data[0][0].plain,
         'The instruction is expected to be found in the %s phase.' %
         'phase-with-target')
Example #27
0
 def test_known_section(self):
     actual = sut.parse(application_help_for(
         [],
         suite_sections=[SectionDocumentationForSectionWithoutInstructionsTestImpl('section A'),
                         SectionDocumentationForSectionWithoutInstructionsTestImpl('section B')]),
         arguments_for.suite_section_for_name('section A'))
     self.assertIsInstance(actual,
                           TestSuiteHelpRequest,
                           'Expecting help for Suite Section')
     assert isinstance(actual,
                       TestSuiteHelpRequest)
     self.assertIs(TestSuiteHelpItem.SECTION,
                   actual.item,
                   'Item should denote help for a Section')
     self.assertIsInstance(actual.data,
                           SectionDocumentation)
Example #28
0
    def test_existing_phase_with_instructions(self):
        # ARRANGE #
        phase_name = 'the phase name'
        instructions = [phase_name, 'name-that-is-not-the-name-of-a-phase']
        application_help = application_help_for([
            section_documentation(phase_name, instructions),
            section_documentation('other phase than ' + phase_name, instructions)
        ])
        # ACT #
        actual = sut.parse(application_help,
                           arguments_for.case_instructions_in_phase(phase_name))

        # ASSERT #
        expectation = asrt_request.matches_test_case_help_request(
            item=asrt.equals(TestCaseHelpItem.PHASE_INSTRUCTION_LIST),
            name=asrt.equals(phase_name),
            data=matches_section_documentation(name=asrt.equals(phase_name)),
            do_include_name_in_output=asrt.is_false)

        expectation.apply_without_message(self, actual)
Example #29
0
 def test_instruction_in_multiple_phase(self):
     application_help = application_help_for([
         section_documentation('phase-a', ['a-instr']),
         section_documentation('phase-b', ['the-instr']),
         section_documentation('phase-c', ['c-instr']),
         section_documentation('phase-d', ['the-instr']),
     ])
     actual = sut.parse(application_help,
                        arguments_for.case_instruction_search('the-instr'))
     actual = self._assert_is_valid_instruction_list_settings('the-instr',
                                                              actual)
     self.assertEqual(2,
                      len(actual.data),
                      'Two instructions are expected to be found')
     self.assertEqual('phase-b',
                      actual.data[0][0].plain,
                      'The first instruction is expected to be found in the %s phase.' % 'phase-b')
     self.assertEqual('phase-d',
                      actual.data[1][0].plain,
                      'The second instruction is expected to be found in the %s phase.' % 'phase-d')
Example #30
0
 def test_instruction_in_multiple_phase(self):
     application_help = application_help_for([
         section_documentation('phase-a', ['a-instr']),
         section_documentation('phase-b', ['the-instr']),
         section_documentation('phase-c', ['c-instr']),
         section_documentation('phase-d', ['the-instr']),
     ])
     actual = sut.parse(application_help,
                        arguments_for.case_instruction_search('the-instr'))
     actual = self._assert_is_valid_instruction_list_settings(
         'the-instr', actual)
     self.assertEqual(2, len(actual.data),
                      'Two instructions are expected to be found')
     self.assertEqual(
         'phase-b', actual.data[0][0].plain,
         'The first instruction is expected to be found in the %s phase.' %
         'phase-b')
     self.assertEqual(
         'phase-d', actual.data[1][0].plain,
         'The second instruction is expected to be found in the %s phase.' %
         'phase-d')
Example #31
0
    def test_existing_phase_with_instructions(self):
        # ARRANGE #
        phase_name = 'the phase name'
        instructions = [phase_name, 'name-that-is-not-the-name-of-a-phase']
        application_help = application_help_for([
            section_documentation(phase_name, instructions),
            section_documentation('other phase than ' + phase_name,
                                  instructions)
        ])
        # ACT #
        actual = sut.parse(
            application_help,
            arguments_for.case_instructions_in_phase(phase_name))

        # ASSERT #
        expectation = asrt_request.matches_test_case_help_request(
            item=asrt.equals(TestCaseHelpItem.PHASE_INSTRUCTION_LIST),
            name=asrt.equals(phase_name),
            data=matches_section_documentation(name=asrt.equals(phase_name)),
            do_include_name_in_output=asrt.is_false)

        expectation.apply_without_message(self, actual)
Example #32
0
 def test_unknown_instruction(self):
     instructions = ['known-instruction']
     application_help = application_help_for([section_documentation('phase', instructions)])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.case_instruction_search('unknown-instruction'))
Example #33
0
 def test_invalid_usage(self):
     with self.assertRaises(HelpError):
         sut.parse(application_help_for([]),
                   [clo.HTML_DOCUMENTATION, 'superfluous argument'])
Example #34
0
 def test_valid_usage(self):
     actual = sut.parse(application_help_for([]), [clo.HTML_DOCUMENTATION])
     self.assertIsInstance(actual, HtmlDocHelpRequest,
                           'Expecting settings for XHTML')
Example #35
0
 def test_invalid_usage(self):
     with self.assertRaises(HelpError):
         sut.parse(application_help_for([]),
                   [clo.HTML_DOCUMENTATION, 'superfluous argument'])
Example #36
0
 def test_valid_usage(self):
     actual = sut.parse(application_help_for([]),
                        [clo.HTML_DOCUMENTATION])
     self.assertIsInstance(actual,
                           HtmlDocHelpRequest,
                           'Expecting settings for XHTML')