def run_failing_post(self): patch = mock.patch.object( self.permission, "add_principal_to_ace", side_effect=BackendError("boom") ) self.addCleanup(patch.stop) patch.start() self.app.post_json( "/psilos", {"data": {"name": "Amanite"}}, headers=self.headers, status=503 )
def run_failing_post(self): patch = mock.patch.object(self.permission, 'add_principal_to_ace', side_effect=BackendError('boom')) self.addCleanup(patch.stop) patch.start() self.app.post_json('/psilos', {'data': { 'name': 'Amanite' }}, headers=self.headers, status=503)
def run_failing_batch(self): patch = mock.patch.object(self.storage, "delete_all", side_effect=BackendError("boom")) self.addCleanup(patch.stop) patch.start() request_create = { "method": "POST", "path": "/mushrooms", "body": {"data": {"name": "Amanite"}}, } request_delete = {"method": "DELETE", "path": "/mushrooms"} body = {"requests": [request_create, request_create, request_delete]} self.app.post_json("/batch", body, headers=self.headers, status=503)
def test_events_are_not_sent_if_subrequest_fails(self): patch = mock.patch.object(self.storage, "delete_all", side_effect=BackendError("boom")) patch.start() self.addCleanup(patch.stop) request_create = {"method": "POST", "body": self.body} request_delete_all = {"method": "DELETE", "body": self.body} body = { "defaults": {"path": self.collection_url}, "requests": [request_create, request_delete_all], } self.app.post_json("/batch", body, headers=self.headers, status=503) self.assertEqual(len(self.events), 0)
def run_failing_batch(self): patch = mock.patch.object(self.storage, 'delete_all', side_effect=BackendError('boom')) self.addCleanup(patch.stop) patch.start() request_create = { 'method': 'POST', 'path': '/mushrooms', 'body': { 'data': { 'name': 'Amanite' } } } request_delete = {'method': 'DELETE', 'path': '/mushrooms'} body = {'requests': [request_create, request_create, request_delete]} self.app.post_json('/batch', body, headers=self.headers, status=503)
def cache_and_fails(this, *args, **kwargs): self.cache.set("test-cache", "a value", ttl=100) raise BackendError("boom")
def cache_and_fails(this, *args, **kwargs): self.cache.set('test-cache', 'a value', ttl=100) raise BackendError('boom')