Merge lp:~thisfred/u1db/bug-1029569 into lp:u1db

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 434
Merged at revision: 434
Proposed branch: lp:~thisfred/u1db/bug-1029569
Merge into: lp:u1db
Diff against target: 52 lines (+11/-2)
2 files modified
u1db/remote/http_app.py (+1/-1)
u1db/tests/test_http_app.py (+10/-1)
To merge this branch: bzr merge lp:~thisfred/u1db/bug-1029569
Reviewer Review Type Date Requested Status
dobey (community) Approve
Review via email: mp+129753@code.launchpad.net

Commit message

handle empty value for doc ids correctly

Description of the change

handle empty value for doc ids correctly

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1db/remote/http_app.py'
2--- u1db/remote/http_app.py 2012-10-12 14:51:08 +0000
3+++ u1db/remote/http_app.py 2012-10-15 20:19:24 +0000
4@@ -49,7 +49,7 @@
5
6
7 def parse_list(expression):
8- if expression is None:
9+ if not expression:
10 return []
11 return [t.strip() for t in expression.split(',')]
12
13
14=== modified file 'u1db/tests/test_http_app.py'
15--- u1db/tests/test_http_app.py 2012-10-12 14:00:15 +0000
16+++ u1db/tests/test_http_app.py 2012-10-15 20:19:24 +0000
17@@ -286,7 +286,7 @@
18 'CONTENT_TYPE': 'application/json ; charset="utf-8"'}
19 invoke = http_app.HTTPInvocationByMethodWithBody(resource, environ,
20 parameters)
21- res = invoke()
22+ invoke()
23 self.assertEqual('{"body": true}', resource.content)
24
25 def test_put_sync_stream(self):
26@@ -721,6 +721,13 @@
27 "has_conflicts": False}]
28 self.assertEqual(expected, json.loads(resp.body))
29
30+ def test_get_docs_empty_docids(self):
31+ resp = self.app.get('/db0/docs?doc_ids=', expect_errors=True)
32+ self.assertEqual(400, resp.status)
33+ self.assertEqual('application/json', resp.header('content-type'))
34+ self.assertEqual(
35+ {"error": "missing document ids"}, json.loads(resp.body))
36+
37 def test_get_docs_missing_doc_ids(self):
38 resp = self.app.get('/db0/docs', expect_errors=True)
39 self.assertEqual(400, resp.status)
40@@ -787,10 +794,12 @@
41 self.assertEqual(200, resp.status)
42 self.assertEqual(
43 'application/json', resp.header('content-type'))
44+
45 def doc_to_dic(doc):
46 return dict(doc_id=doc.doc_id, doc_rev=doc.rev,
47 content=doc.get_json(),
48 has_conflicts=doc.has_conflicts)
49+
50 expected = sorted([doc_to_dic(doc1), doc_to_dic(doc2)])
51 self.assertEqual(expected, sorted(json.loads(resp.body)))
52 self.assertEqual(2, int(resp.header('x-u1db-generation')))

Subscribers

People subscribed via source and target branches