Beispiel #1
0
 def test_requestsync_urlopen_error(self):
     "test requestsync when urlopen raises an exception"
     with dingus.patch("urllib2.urlopen",
                       dingus.exception_raiser(IOError("you fail"))):
         result = self.server.requestsync()
         self.assertFalse(result["success"])
         self.assertEqual(result["message"], "you fail")
    def setup(self):
        BaseFindAndModify.setup(self)
        self.MyDoc.database.command = exception_raiser(
            OperationFailure(Dingus()))

        self.returned = self.MyDoc.find_and_modify(
            self.query, self.update, **self.kwargs)
    def test_rejects_bad_json(self):
        mod.json = Dingus()
        mod.json.loads = exception_raiser(ValueError)
        resp = self.client.post('/queue/foo/', headers=[('X-httPQueue-Priority', '2011-01-13T02:00:51.577113')],
                                content_type='application/json')

        self.assertEqual(resp.status_code, 415)
Beispiel #4
0
 def setup(self):
     exception = ValueError()
     self.raise_exception = exception_raiser(exception)
    def setup(self):
        DescribePriorityQueue.setup(self)

        mod.ObjectId = exception_raiser(mod.PymongoInvalidId)
Beispiel #6
0
 def test_requestsync_urlopen_error(self):
     "test requestsync when urlopen raises an exception"
     with dingus.patch("urllib2.urlopen", dingus.exception_raiser(IOError("you fail"))):
         result = self.server.requestsync()
         self.assertFalse(result["success"])
         self.assertEqual(result["message"], "you fail")
    def test_ack_invalid_id_returns_404(self):
        mod.model.get_queue().ack = exception_raiser(mod.model.errors.InvalidId)
        resp = self.client.open(method='ACK', path='/queue/foo/id/NotValid')

        self.assertEqual(resp.status_code, 404)
    def test_ack_nonexistant_returns_404(self):
        mod.model.get_queue().ack = exception_raiser(KeyError)
        resp = self.client.open(method='ACK', path='/queue/foo/id/1')

        self.assertEqual(resp.status_code, 404)
Beispiel #9
0
 def raises_URL_error_when_socket_error_happens():
     mod.socket.error = socket.error
     current_http_connection().request = exception_raiser(mod.socket.error)
     with expect.raises(URLError):
         HTTPHandler().http_open(req)