示例#1
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'))
示例#2
0
 def test_unknown_instruction(self):
     application_help = application_help_for_suite_sections([
         section_documentation('section-1', ['instruction']),
         section_documentation('empty-section', []),
     ])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.suite_instruction_in_section('empty-section', 'instruction'))
示例#3
0
 def test_unknown_instruction(self):
     application_help = application_help_for_suite_sections([
         section_documentation('section-1', ['instruction']),
         section_documentation('empty-section', []),
     ])
     with self.assertRaises(HelpError):
         sut.parse(
             application_help,
             arguments_for.suite_instruction_in_section(
                 'empty-section', 'instruction'))
示例#4
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'))
示例#5
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')
示例#6
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)
示例#7
0
 def test_single_instruction_for_section_with_instructions(self):
     section_name = 'the section name'
     instructions = [section_name, 'name-that-is-not-the-name-of-a-section']
     application_help = application_help_for_suite_sections([
         section_documentation(section_name, instructions),
         section_documentation('other section than ' + section_name, instructions)
     ])
     self._assert_is_existing_instruction_in_section(application_help,
                                                     section_name,
                                                     'name-that-is-not-the-name-of-a-section')
     self._assert_is_existing_instruction_in_section(application_help,
                                                     section_name,
                                                     section_name)
示例#8
0
 def test_single_instruction_for_section_with_instructions(self):
     section_name = 'the section name'
     instructions = [section_name, 'name-that-is-not-the-name-of-a-section']
     application_help = application_help_for_suite_sections([
         section_documentation(section_name, instructions),
         section_documentation('other section than ' + section_name,
                               instructions)
     ])
     self._assert_is_existing_instruction_in_section(
         application_help, section_name,
         'name-that-is-not-the-name-of-a-section')
     self._assert_is_existing_instruction_in_section(
         application_help, section_name, section_name)
示例#9
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)
示例#10
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')
示例#11
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'))
示例#12
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'))
示例#13
0
 def test_unknown_section(self):
     application_help = application_help_for_suite_sections([
         section_documentation('section', ['instruction-name'])
     ])
     with self.assertRaises(HelpError):
         sut.parse(application_help,
                   arguments_for.suite_instruction_in_section('non-existing-section', 'instruction-name'))
示例#14
0
 def test_unknown_section(self):
     application_help = application_help_for_suite_sections(
         [section_documentation('section', ['instruction-name'])])
     with self.assertRaises(HelpError):
         sut.parse(
             application_help,
             arguments_for.suite_instruction_in_section(
                 'non-existing-section', 'instruction-name'))
示例#15
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'))
示例#16
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)
示例#17
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')
示例#18
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')
示例#19
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)
示例#20
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'))
示例#21
0
 def _application_help_with_phases(self, all_phases: Iterable[str]):
     return ApplicationHelp(
         MainProgramHelp(),
         TestCaseHelp(
             map(lambda ph_name: section_documentation(ph_name, []),
                 all_phases)), TestSuiteHelp([], []), {})
示例#22
0
 def _application_help_with_phases(self, all_phases: Iterable[str]):
     return ApplicationHelp(MainProgramHelp(),
                            TestCaseHelp(map(lambda ph_name: section_documentation(ph_name, []),
                                             all_phases)),
                            TestSuiteHelp([], []),
                            {})