Exemplo n.º 1
0
    def test_none(self):
        jobtype = JobType(fake_assignment())

        with patch.object(logger, "error") as mocked_error:
            self.assertIsNone(jobtype.format_error(None))

        mocked_error.assert_called_with(
            "No error was defined for this failure.")
Exemplo n.º 2
0
    def test_process_done(self):
        error = Failure(exc_value=Exception())
        error.type = ProcessDone
        error.value = Mock(exitCode=1, message="foobar")

        jobtype = JobType(fake_assignment())
        self.assertEqual(
            jobtype.format_error(error),
            "Process has finished with no apparent errors."
        )
Exemplo n.º 3
0
    def test_process_terminated(self):
        error = Failure(exc_value=Exception())
        error.type = ProcessTerminated
        error.value = Mock(exitCode=1, message="foobar")

        jobtype = JobType(fake_assignment())
        self.assertEqual(
            jobtype.format_error(error),
            "Process may have terminated abnormally, please check "
            "the logs.  Message from error "
            "was 'foobar'"
        )
Exemplo n.º 4
0
    def test_other_conversion_problem(self):
        jobtype = JobType(fake_assignment())

        class OtherType(object):
            def __str__(self):
                raise NotImplementedError("__str__ not implemented")

        other = OtherType()

        try:
            str(other)
        except NotImplementedError as str_error:
            pass

        with patch.object(logger, "error") as mocked_error:
            self.assertIsNone(jobtype.format_error(other))

        mocked_error.assert_called_with(
            "Don't know how to format %r as a string.  Error while calling "
            "str(%r) was %s.", other, str(str_error))
Exemplo n.º 5
0
 def test_other(self):
     jobtype = JobType(fake_assignment())
     self.assertEqual(jobtype.format_error(42), str(42))
Exemplo n.º 6
0
 def test_string(self):
     jobtype = JobType(fake_assignment())
     self.assertEqual(
         jobtype.format_error("This is a string"),
         "This is a string"
     )
Exemplo n.º 7
0
 def test_exception(self):
     jobtype = JobType(fake_assignment())
     self.assertEqual(
         jobtype.format_error(TypeError("foobar 2")),
         "foobar 2"
     )