Ejemplo n.º 1
0
 def test_accessor_exception_from_accessor(self):
     # ARRANGE #
     process_error = tcp.ProcessError(
         error_info.of_exception(ValueError('exception message')))
     accessor = sut.AccessorFromParts(
         SourceReaderThat(raises(process_error)),
         PreprocessorThat(gives_constant('preprocessed source')),
         ParserThat(gives_constant(TEST_CASE)),
         identity_test_case_transformer())
     executor = ExecutorThat(raises(PROCESS_ERROR))
     processor = sut.ProcessorFromAccessorAndExecutor(accessor, executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertIs(tcp.Status.ACCESS_ERROR, result.status)
     self.assertIs(tcp.AccessErrorType.FILE_ACCESS_ERROR,
                   result.access_error_type)
     self.assertIsNotNone(result.error_info, 'There should be ErrorInfo')
     err_description = result.error_info.description
     self.assertIsInstance(err_description,
                           error_description.ErrorDescriptionOfException)
     assert isinstance(err_description,
                       error_description.ErrorDescriptionOfException)
     self.assertEqual(err_description.exception.args[0],
                      'exception message')
Ejemplo n.º 2
0
 def test_accessor_exception_from_accessor(self):
     # ARRANGE #
     process_error = tcp.ProcessError(
         error_info.of_exception(ValueError('exception message')))
     accessor = sut.AccessorFromParts(SourceReaderThat(raises(process_error)),
                                      PreprocessorThat(gives_constant('preprocessed source')),
                                      ParserThat(gives_constant(TEST_CASE)),
                                      identity_test_case_transformer())
     executor = ExecutorThat(raises(PROCESS_ERROR))
     processor = sut.ProcessorFromAccessorAndExecutor(accessor,
                                                      executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertIs(tcp.Status.ACCESS_ERROR,
                   result.status)
     self.assertIs(tcp.AccessErrorType.FILE_ACCESS_ERROR,
                   result.access_error_type)
     self.assertIsNotNone(result.error_info,
                          'There should be ErrorInfo')
     err_description = result.error_info.description
     self.assertIsInstance(err_description,
                           error_description.ErrorDescriptionOfException)
     assert isinstance(err_description,
                       error_description.ErrorDescriptionOfException)
     self.assertEqual(err_description.exception.args[0],
                      'exception message')
Ejemplo n.º 3
0
 def test_parser_that_raises(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(SourceReaderThat(gives_constant('source')),
                                      PreprocessorThat(gives_constant('preprocessed source')),
                                      ParserThat(raises(PROCESS_ERROR)),
                                      identity_test_case_transformer())
     # ACT #
     with self.assertRaises(tcp.AccessorError) as cm:
         accessor.apply(TEST_CASE_REFERENCE)
     # ASSERT #
     self.assertEqual(cm.exception.error,
                      tcp.AccessErrorType.SYNTAX_ERROR)
Ejemplo n.º 4
0
 def test_source_reader_that_raises(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(SourceReaderThat(raises(PROCESS_ERROR)),
                                      PreprocessorThat(raises_should_not_be_invoked_error),
                                      ParserThat(raises_should_not_be_invoked_error),
                                      identity_test_case_transformer())
     # ACT #
     with self.assertRaises(tcp.AccessorError) as cm:
         accessor.apply(TEST_CASE_REFERENCE)
     # ASSERT #
     self.assertEqual(cm.exception.error,
                      tcp.AccessErrorType.FILE_ACCESS_ERROR)
Ejemplo n.º 5
0
 def test_implementation_exception_from_executor(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(
         SourceReaderThat(gives_constant('source')),
         PreprocessorThat(gives_constant('preprocessed source')),
         ParserThat(gives_constant(TEST_CASE)),
         identity_test_case_transformer())
     executor = ExecutorThat(raises(RuntimeError()))
     processor = sut.ProcessorFromAccessorAndExecutor(accessor, executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertEqual(tcp.Status.INTERNAL_ERROR, result.status)
Ejemplo n.º 6
0
 def test_successful_application(self):
     # ARRANGE #
     source = 'SOURCE'
     p_source = 'PREPROCESSED SOURCE'
     accessor = sut.AccessorFromParts(
         SourceReaderThatReturnsIfSame(PATH, source),
         PreprocessorThatReturnsIfSame(source, p_source),
         ParserThatReturnsIfSame(p_source, TEST_CASE),
         identity_test_case_transformer())
     # ACT #
     actual = accessor.apply(TEST_CASE_REFERENCE)
     # ASSERT #
     self.assertIs(TEST_CASE, actual)
Ejemplo n.º 7
0
 def test_successful_application(self):
     # ARRANGE #
     source = 'SOURCE'
     p_source = 'PREPROCESSED SOURCE'
     accessor = sut.AccessorFromParts(SourceReaderThatReturnsIfSame(PATH, source),
                                      PreprocessorThatReturnsIfSame(source, p_source),
                                      ParserThatReturnsIfSame(p_source, TEST_CASE),
                                      identity_test_case_transformer())
     # ACT #
     actual = accessor.apply(TEST_CASE_REFERENCE)
     # ASSERT #
     self.assertIs(TEST_CASE,
                   actual)
Ejemplo n.º 8
0
 def test_implementation_exception_from_executor(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(SourceReaderThat(gives_constant('source')),
                                      PreprocessorThat(gives_constant('preprocessed source')),
                                      ParserThat(gives_constant(TEST_CASE)),
                                      identity_test_case_transformer())
     executor = ExecutorThat(raises(RuntimeError()))
     processor = sut.ProcessorFromAccessorAndExecutor(accessor,
                                                      executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertEqual(tcp.Status.INTERNAL_ERROR,
                      result.status)
Ejemplo n.º 9
0
    def test_parser_that_raises(self):
        # ARRANGE #
        accessor = sut.AccessorFromParts(
            SourceReaderThat(gives_constant('source')),
            PreprocessorThat(gives_constant('preprocessed source')),
            ParserThat(raises(PROCESS_ERROR)),
            identity_test_case_transformer())
        # ACT #
        with self.assertRaises(tcp.AccessorError) as cm:
            accessor.apply(TEST_CASE_REFERENCE)
        # ASSERT #
        expectation = asrt_tc_proc.accessor_error_matches(
            error=asrt.equals(tcp.AccessErrorType.SYNTAX_ERROR))

        expectation.apply_with_message(self, cm.exception, 'exception data')
Ejemplo n.º 10
0
    def test_source_reader_that_raises(self):
        # ARRANGE #
        accessor = sut.AccessorFromParts(
            SourceReaderThat(raises(PROCESS_ERROR)),
            PreprocessorThat(raises_should_not_be_invoked_error),
            ParserThat(raises_should_not_be_invoked_error),
            identity_test_case_transformer())
        # ACT #
        with self.assertRaises(tcp.AccessorError) as cm:
            accessor.apply(TEST_CASE_REFERENCE)
        # ASSERT #
        expectation = asrt_tc_proc.accessor_error_matches(
            error=asrt.equals(tcp.AccessErrorType.FILE_ACCESS_ERROR))

        expectation.apply_with_message(self, cm.exception, 'exception data')
Ejemplo n.º 11
0
 def test_successful_application(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(
         SourceReaderThat(gives_constant('source')),
         PreprocessorThat(gives_constant('preprocessed source')),
         ParserThat(gives_constant(TEST_CASE)),
         identity_test_case_transformer())
     full_result = new_skipped()
     executor = ExecutorThatReturnsIfSame(TEST_CASE, full_result)
     processor = sut.ProcessorFromAccessorAndExecutor(accessor, executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertIs(tcp.Status.EXECUTED, result.status)
     self.assertIs(full_result, result.execution_result)
Ejemplo n.º 12
0
 def test_successful_application(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(SourceReaderThat(gives_constant('source')),
                                      PreprocessorThat(gives_constant('preprocessed source')),
                                      ParserThat(gives_constant(TEST_CASE)),
                                      identity_test_case_transformer())
     full_result = new_skipped()
     executor = ExecutorThatReturnsIfSame(TEST_CASE, full_result)
     processor = sut.ProcessorFromAccessorAndExecutor(accessor,
                                                      executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertIs(tcp.Status.EXECUTED,
                   result.status)
     self.assertIs(full_result,
                   result.execution_result)