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'))
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'))
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'))
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'))
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))
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'))
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'))
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'))
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'))
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))
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'))
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'))
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'))
def runTest(self): # ARRANGE # actors = [ self.setup.entity_with_name('first'), self.setup.entity_with_name('second'), ] application_help = self.setup.application_help_for_list_of_entities(actors) # ACT & ASSERT # with self.assertRaises(HelpError): sut.parse(application_help, self.setup.arguments_for_single_entity('non-existing actor'))
def runTest(self): # ARRANGE # actors = [ self.setup.entity_with_name('first'), self.setup.entity_with_name('second'), ] application_help = self.setup.application_help_for_list_of_entities( actors) # ACT & ASSERT # with self.assertRaises(HelpError): sut.parse( application_help, self.setup.arguments_for_single_entity('non-existing actor'))
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')
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')
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')
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')
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')
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')
def runTest(self): # ARRANGE # actors = [ self.setup.entity_with_name('first'), self.setup.entity_with_name('second'), ] application_help = self.setup.application_help_for_list_of_entities(actors) # ACT # actual = sut.parse(application_help, self.setup.arguments_for_single_entity('second')) # ASSERT # _assert_result_is_individual_entity(self, self.setup, actual, 'second')
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')
def runTest(self): # ARRANGE # actors = [ self.setup.entity_with_name('first'), self.setup.entity_with_name('second'), ] application_help = self.setup.application_help_for_list_of_entities( actors) # ACT # actual = sut.parse(application_help, self.setup.arguments_for_single_entity('second')) # ASSERT # _assert_result_is_individual_entity(self, self.setup, actual, 'second')
def runTest(self): arguments = self.setup.arguments_for_list() actual = sut.parse(self.setup.application_help_for_list_of_entities([]), arguments) self.assertIsInstance(actual, EntityHelpRequest, 'Expecting settings for {}s'.format(self.setup.entity_type_name)) assert isinstance(actual, EntityHelpRequest, ) self.assertEqual(actual.entity_type, self.setup.entity_type_name, 'Expecting settings for {}s'.format(self.setup.entity_type_name)) self.assertIs(EntityHelpItem.ALL_ENTITIES_LIST, actual.item, 'Item should denote help for ' + EntityHelpItem.ALL_ENTITIES_LIST.name)
def runTest(self): # ARRANGE # actors = [ self.setup.entity_with_name('first'), self.setup.entity_with_name('a b c'), self.setup.entity_with_name('last'), ] application_help = self.setup.application_help_for_list_of_entities(actors) # ACT # actual = sut.parse(application_help, self.setup.arguments_for_single_entity('a B C')) # ASSERT # _assert_result_is_individual_entity(self, self.setup, actual, 'a b c', check_is_include_entity_name_in_output=False)
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')
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)
def _assert_is_existing_instruction_in_section( self, application_help: ApplicationHelp, section_name: str, instruction_name: str): actual = sut.parse( application_help, arguments_for.suite_instruction_in_section(section_name, instruction_name)) actual = self._check_is_test_suite_settings_for_single_instruction( actual) self.assertEqual(actual.name, instruction_name, 'Name of instruction') single_line_desc_str = actual.data.single_line_description() self.assertEqual( single_line_description_that_identifies_instruction_and_section( section_name, instruction_name), single_line_desc_str, 'The single-line-description in this test is expected to identify (section,instruction-name)' )
def _assert_is_existing_instruction_in_section(self, application_help: ApplicationHelp, section_name: str, instruction_name: str): actual = sut.parse(application_help, arguments_for.suite_instruction_in_section(section_name, instruction_name)) actual = self._check_is_test_suite_settings_for_single_instruction(actual) self.assertEqual(actual.name, instruction_name, 'Name of instruction') single_line_desc_str = actual.data.single_line_description() self.assertEqual(single_line_description_that_identifies_instruction_and_section(section_name, instruction_name), single_line_desc_str, 'The single-line-description in this test is expected to identify (section,instruction-name)')
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)
def runTest(self): arguments = self.setup.arguments_for_list() actual = sut.parse( self.setup.application_help_for_list_of_entities([]), arguments) self.assertIsInstance( actual, EntityHelpRequest, 'Expecting settings for {}s'.format(self.setup.entity_type_name)) assert isinstance( actual, EntityHelpRequest, ) self.assertEqual( actual.entity_type, self.setup.entity_type_name, 'Expecting settings for {}s'.format(self.setup.entity_type_name)) self.assertIs( EntityHelpItem.ALL_ENTITIES_LIST, actual.item, 'Item should denote help for ' + EntityHelpItem.ALL_ENTITIES_LIST.name)
def runTest(self): # ARRANGE # actors = [ self.setup.entity_with_name('first'), self.setup.entity_with_name('a b c'), self.setup.entity_with_name('last'), ] application_help = self.setup.application_help_for_list_of_entities( actors) # ACT # actual = sut.parse(application_help, self.setup.arguments_for_single_entity('a B C')) # ASSERT # _assert_result_is_individual_entity( self, self.setup, actual, 'a b c', check_is_include_entity_name_in_output=False)
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)
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')
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')
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)
def _assert_successful_parsing_of_existing_phase( self, application_help: ApplicationHelp, phase_name: str): arguments = arguments_for.case_phase_for_name(phase_name) actual = sut.parse(application_help, arguments) self._assert_is_single_phase_help(phase_name, actual)
def test_non_existing_phases(self): application_help = self._application_help_with_phases( ['phase 1', 'phase 2']) arguments = arguments_for.case_phase_for_name('non existing phase') with self.assertRaises(HelpError): sut.parse(application_help, arguments)
def test_invalid_usage(self): with self.assertRaises(HelpError): sut.parse(application_help_for([]), [clo.HTML_DOCUMENTATION, 'superfluous argument'])
def test_valid_usage(self): actual = sut.parse(application_help_for([]), [clo.HTML_DOCUMENTATION]) self.assertIsInstance(actual, HtmlDocHelpRequest, 'Expecting settings for XHTML')
def _assert_successful_parsing_of_existing_phase(self, application_help: ApplicationHelp, phase_name: str): arguments = arguments_for.case_phase_for_name(phase_name) actual = sut.parse(application_help, arguments) self._assert_is_single_phase_help(phase_name, actual)
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'))
def test_non_existing_phases(self): application_help = self._application_help_with_phases(['phase 1', 'phase 2']) arguments = arguments_for.case_phase_for_name('non existing phase') with self.assertRaises(HelpError): sut.parse(application_help, arguments)