Merge lp:~thisfred/u1db/quota-error-handling into lp:u1db

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 350
Merged at revision: 350
Proposed branch: lp:~thisfred/u1db/quota-error-handling
Merge into: lp:u1db
Diff against target: 86 lines (+25/-0)
5 files modified
include/u1db/u1db.h (+1/-0)
u1db/errors.py (+6/-0)
u1db/remote/http_errors.py (+1/-0)
u1db/tests/c_backend_wrapper.pyx (+3/-0)
u1db/tests/test_http_client.py (+14/-0)
To merge this branch: bzr merge lp:~thisfred/u1db/quota-error-handling
Reviewer Review Type Date Requested Status
John O'Brien (community) Approve
Review via email: mp+114472@code.launchpad.net

Commit message

added quota error client tests for quota and document too big

Description of the change

added quota error client tests for quota and document too big

To post a comment you must log in.
Revision history for this message
John O'Brien (jdobrien) wrote :

This looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/u1db/u1db.h'
--- include/u1db/u1db.h 2012-07-09 17:43:47 +0000
+++ include/u1db/u1db.h 2012-07-11 17:26:19 +0000
@@ -75,6 +75,7 @@
75#define U1DB_INVALID_GENERATION -2175#define U1DB_INVALID_GENERATION -21
76#define U1DB_TARGET_UNAVAILABLE -2276#define U1DB_TARGET_UNAVAILABLE -22
77#define U1DB_DOCUMENT_TOO_BIG -2377#define U1DB_DOCUMENT_TOO_BIG -23
78#define U1DB_USER_QUOTA_EXCEEDED -24
78#define U1DB_INTERNAL_ERROR -99979#define U1DB_INTERNAL_ERROR -999
7980
80// Used by put_doc_if_newer81// Used by put_doc_if_newer
8182
=== modified file 'u1db/errors.py'
--- u1db/errors.py 2012-07-09 17:43:47 +0000
+++ u1db/errors.py 2012-07-11 17:26:19 +0000
@@ -49,6 +49,12 @@
49 wire_description = "document too big"49 wire_description = "document too big"
5050
5151
52class UserQuotaExceeded(U1DBError):
53 """Document exceeds the maximum document size for this database."""
54
55 wire_description = "user quota exceeded"
56
57
52class InvalidTransactionId(U1DBError):58class InvalidTransactionId(U1DBError):
53 """Invalid transaction for generation."""59 """Invalid transaction for generation."""
5460
5561
=== modified file 'u1db/remote/http_errors.py'
--- u1db/remote/http_errors.py 2012-07-09 21:00:06 +0000
+++ u1db/remote/http_errors.py 2012-07-11 17:26:19 +0000
@@ -26,6 +26,7 @@
26 (errors.InvalidDocId.wire_description, 400),26 (errors.InvalidDocId.wire_description, 400),
27 (errors.Unauthorized.wire_description, 401),27 (errors.Unauthorized.wire_description, 401),
28 (errors.DocumentTooBig.wire_description, 403),28 (errors.DocumentTooBig.wire_description, 403),
29 (errors.UserQuotaExceeded.wire_description, 403),
29 (errors.DatabaseDoesNotExist.wire_description, 404),30 (errors.DatabaseDoesNotExist.wire_description, 404),
30 (errors.DocumentDoesNotExist.wire_description, 404),31 (errors.DocumentDoesNotExist.wire_description, 404),
31 (errors.DocumentAlreadyDeleted.wire_description, 404),32 (errors.DocumentAlreadyDeleted.wire_description, 404),
3233
=== modified file 'u1db/tests/c_backend_wrapper.pyx'
--- u1db/tests/c_backend_wrapper.pyx 2012-07-10 17:55:45 +0000
+++ u1db/tests/c_backend_wrapper.pyx 2012-07-11 17:26:19 +0000
@@ -130,6 +130,7 @@
130 int U1DB_NOT_IMPLEMENTED130 int U1DB_NOT_IMPLEMENTED
131 int U1DB_INVALID_JSON131 int U1DB_INVALID_JSON
132 int U1DB_DOCUMENT_TOO_BIG132 int U1DB_DOCUMENT_TOO_BIG
133 int U1DB_USER_QUOTA_EXCEEDED
133 int U1DB_INVALID_VALUE_FOR_INDEX134 int U1DB_INVALID_VALUE_FOR_INDEX
134 int U1DB_INVALID_GLOBBING135 int U1DB_INVALID_GLOBBING
135 int U1DB_BROKEN_SYNC_STREAM136 int U1DB_BROKEN_SYNC_STREAM
@@ -608,6 +609,8 @@
608 raise errors.InvalidJSON609 raise errors.InvalidJSON
609 if status == U1DB_DOCUMENT_TOO_BIG:610 if status == U1DB_DOCUMENT_TOO_BIG:
610 raise errors.DocumentTooBig611 raise errors.DocumentTooBig
612 if status == U1DB_USER_QUOTA_EXCEEDED:
613 raise errors.UserQuotaExceeded
611 raise RuntimeError('%s (status: %s)' % (context, status))614 raise RuntimeError('%s (status: %s)' % (context, status))
612615
613616
614617
=== modified file 'u1db/tests/test_http_client.py'
--- u1db/tests/test_http_client.py 2012-06-25 14:25:49 +0000
+++ u1db/tests/test_http_client.py 2012-07-11 17:26:19 +0000
@@ -275,6 +275,20 @@
275 self.assertTrue("content-type" in e.headers)275 self.assertTrue("content-type" in e.headers)
276 self.assertEqual(5, self.errors)276 self.assertEqual(5, self.errors)
277277
278 def test_document_too_big(self):
279 cli = self.getClient()
280 self.assertRaises(errors.DocumentTooBig,
281 cli._request_json, 'POST', ['error'], {},
282 {'status': "403 Forbidden",
283 'response': {"error": "document too big"}})
284
285 def test_user_quota_exceeded(self):
286 cli = self.getClient()
287 self.assertRaises(errors.UserQuotaExceeded,
288 cli._request_json, 'POST', ['error'], {},
289 {'status': "403 Forbidden",
290 'response': {"error": "user quota exceeded"}})
291
278 def test_generic_u1db_error(self):292 def test_generic_u1db_error(self):
279 cli = self.getClient()293 cli = self.getClient()
280 self.assertRaises(errors.U1DBError,294 self.assertRaises(errors.U1DBError,

Subscribers

People subscribed via source and target branches