Exemple #1
0
 def test_catch_closed(self):
     """
     This test ensures that L{Closed} exception raised by C{amq_connected}
     is swallowed by L{AMQFactory}.
     """
     errors = flush_logged_errors()
     self.assertEquals(len(errors), 0)
Exemple #2
0
 def test_catch_closed(self):
     """
     This test ensures that L{Closed} exception raised by C{amq_connected}
     is swallowed by L{AMQFactory}.
     """
     errors = flush_logged_errors()
     self.assertEquals(len(errors), 0)
Exemple #3
0
 def test_bad_timestamp(self):
     """
     Valid JSON with an invalid timestamp is an HTTP BAD_REQUEST.
     """
     req = self.submit(self.BAD_TIMESTAMP)
     req.addCallback(self.check_response_code, http.BAD_REQUEST)
     req.addCallback(lambda _: flush_logged_errors(BadRequest))
     return req
Exemple #4
0
 def test_query_with_negative_limit(self):
     """
     ``query`` raises ``BadRequest`` when a negative value is
     specified for the `limit` key.
     """
     d = self.setup_results()
     d.addCallback(self.run_query, limit=-1)
     d.addCallback(self.check_response_code, http.BAD_REQUEST)
     d.addCallback(lambda _: flush_logged_errors(BadRequest))
     return d
Exemple #5
0
 def test_non_integer_limit_query_arg(self):
     """
     ``query`` raises ``BadRequest`` when a non-integer value is
     is specified for the `limit` key.
     """
     d = self.setup_results()
     d.addCallback(self.run_query, limit="one")
     d.addCallback(self.check_response_code, http.BAD_REQUEST)
     d.addCallback(lambda _: flush_logged_errors(BadRequest))
     return d
Exemple #6
0
 def test_multiple_query_args_of_same_type(self):
     """
     ``query`` raises ``BadRequest`` when multiple values for a key
     are specified.
     """
     d = self.setup_results()
     d.addCallback(self.run_query, filter={u"branch": [u"1", u"2"]})
     d.addCallback(self.check_response_code, http.BAD_REQUEST)
     d.addCallback(lambda _: flush_logged_errors(BadRequest))
     return d
Exemple #7
0
 def test_unsupported_query_arg(self):
     """
     ``query`` raises ``BadRequest`` when an unsupported query
     argument is specified.
     """
     d = self.setup_results()
     d.addCallback(self.run_query, filter={u"unsupported": u"ignored"})
     d.addCallback(self.check_response_code, http.BAD_REQUEST)
     d.addCallback(lambda _: flush_logged_errors(BadRequest))
     return d
 def test_unexpectedErrorAndNotificationFailure(self):
     # If unexpectedError is called while a notification is pending and the
     # notification subsequently fails, the first failure "wins" and is
     # passed on to the termination deferred.
     deferred = defer.Deferred()
     self.protocol.runNotification(lambda: deferred)
     self.protocol.unexpectedError(makeFailure(TypeError))
     runtime_error_failure = makeFailure(RuntimeError)
     deferred.errback(runtime_error_failure)
     self.assertEqual(flush_logged_errors(RuntimeError),
                      [runtime_error_failure])
     return assert_fails_with(self.termination_deferred, TypeError)
 def test_unexpectedErrorAndNotificationFailure(self):
     # If unexpectedError is called while a notification is pending and the
     # notification subsequently fails, the first failure "wins" and is
     # passed on to the termination deferred.
     deferred = defer.Deferred()
     self.protocol.runNotification(lambda : deferred)
     self.protocol.unexpectedError(makeFailure(TypeError))
     runtime_error_failure = makeFailure(RuntimeError)
     deferred.errback(runtime_error_failure)
     self.assertEqual(
         flush_logged_errors(RuntimeError), [runtime_error_failure])
     return assert_fails_with(
         self.termination_deferred, TypeError)
 def test_uncleanExitAndPendingNotificationFails(self):
     # If the process exits with a non-zero exit code while a
     # notification is pending and the notification subsequently
     # fails, the ProcessTerminated is still passed on to the
     # termination deferred.
     deferred = defer.Deferred()
     self.protocol.runNotification(lambda: deferred)
     self.simulateProcessExit(clean=False)
     runtime_error_failure = makeFailure(RuntimeError)
     deferred.errback(runtime_error_failure)
     self.assertEqual(flush_logged_errors(RuntimeError),
                      [runtime_error_failure])
     return assert_fails_with(self.termination_deferred,
                              error.ProcessTerminated)
 def test_uncleanExitAndPendingNotificationFails(self):
     # If the process exits with a non-zero exit code while a
     # notification is pending and the notification subsequently
     # fails, the ProcessTerminated is still passed on to the
     # termination deferred.
     deferred = defer.Deferred()
     self.protocol.runNotification(lambda : deferred)
     self.simulateProcessExit(clean=False)
     runtime_error_failure = makeFailure(RuntimeError)
     deferred.errback(runtime_error_failure)
     self.assertEqual(
         flush_logged_errors(RuntimeError), [runtime_error_failure])
     return assert_fails_with(
         self.termination_deferred, error.ProcessTerminated)
    def test_errorBeforeStatusReportAndFailingMirrorFailed(self):
        # If the subprocess exits before reporting success or failure, *and*
        # the attempt to record failure fails, there's not much we can do but
        # we should still not hang.  In keeping with the general policy, we
        # fire the termination deferred with the first thing to go wrong --
        # the process termination in this case -- and log.err() the failed
        # attempt to call mirrorFailed().

        runtime_error_failure = makeFailure(RuntimeError)

        class FailingMirrorFailedStubPullerListener(self.StubPullerListener):
            def mirrorFailed(self, message, oops):
                return runtime_error_failure

        self.protocol.listener = FailingMirrorFailedStubPullerListener()
        self.listener = self.protocol.listener
        self.protocol.errReceived('traceback')
        self.simulateProcessExit(clean=False)
        self.assertEqual(
            flush_logged_errors(RuntimeError), [runtime_error_failure])
        return assert_fails_with(
            self.termination_deferred, error.ProcessTerminated)
    def test_errorBeforeStatusReportAndFailingMirrorFailed(self):
        # If the subprocess exits before reporting success or failure, *and*
        # the attempt to record failure fails, there's not much we can do but
        # we should still not hang.  In keeping with the general policy, we
        # fire the termination deferred with the first thing to go wrong --
        # the process termination in this case -- and log.err() the failed
        # attempt to call mirrorFailed().

        runtime_error_failure = makeFailure(RuntimeError)

        class FailingMirrorFailedStubPullerListener(self.StubPullerListener):
            def mirrorFailed(self, message, oops):
                return runtime_error_failure

        self.protocol.listener = FailingMirrorFailedStubPullerListener()
        self.listener = self.protocol.listener
        self.protocol.errReceived('traceback')
        self.simulateProcessExit(clean=False)
        self.assertEqual(flush_logged_errors(RuntimeError),
                         [runtime_error_failure])
        return assert_fails_with(self.termination_deferred,
                                 error.ProcessTerminated)
 def check_finishJob_called(result):
     self.assertEqual(
         [('finishJobID', job_id, 'SUCCESS', '')],
         worker_monitor.codeimport_endpoint.calls)
     errors = flush_logged_errors(Fail)
     self.assertEqual(1, len(errors))
Exemple #15
0
 def check_finishJob_called(result):
     self.assertEqual([('finishJobID', job_id, 'SUCCESS', '')],
                      worker_monitor.codeimport_endpoint.calls)
     errors = flush_logged_errors(Fail)
     self.assertEqual(1, len(errors))
 def flush_errback(f):
     flush_logged_errors(BadKeyError)
     return f