Merge lp:~thisfred/u1db/fix-error-msg into lp:u1db

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 421
Merged at revision: 420
Proposed branch: lp:~thisfred/u1db/fix-error-msg
Merge into: lp:u1db
Diff against target: 26 lines (+5/-0)
2 files modified
u1db/backends/__init__.py (+2/-0)
u1db/tests/test_backends.py (+3/-0)
To merge this branch: bzr merge lp:~thisfred/u1db/fix-error-msg
Reviewer Review Type Date Requested Status
Lucio Torre (community) Approve
Review via email: mp+128357@code.launchpad.net

Commit message

Fixed the error message in the case a user provides JSON to create_doc, which expects a Python dictionary.

Description of the change

Fixed the error message in the case a user provides JSON to create_doc, which expects a Python dictionary.

To post a comment you must log in.
Revision history for this message
Lucio Torre (lucio.torre) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

The attempt to merge lp:~thisfred/u1db/fix-error-msg into lp:u1db failed. Below is the output from the failed tests.

/bin/sh: 1: cmake: not found

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

The attempt to merge lp:~thisfred/u1db/fix-error-msg into lp:u1db failed. Below is the output from the failed tests.

/bin/sh: 1: cmake: not found

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

The attempt to merge lp:~thisfred/u1db/fix-error-msg into lp:u1db failed. Below is the output from the failed tests.

/bin/sh: 1: cmake: not found

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1db/backends/__init__.py'
2--- u1db/backends/__init__.py 2012-08-14 14:31:45 +0000
3+++ u1db/backends/__init__.py 2012-10-06 16:19:20 +0000
4@@ -88,6 +88,8 @@
5 raise NotImplementedError(self._has_conflicts)
6
7 def create_doc(self, content, doc_id=None):
8+ if not isinstance(content, dict):
9+ raise errors.InvalidContent
10 json_string = json.dumps(content)
11 if doc_id is None:
12 doc_id = self._allocate_doc_id()
13
14=== modified file 'u1db/tests/test_backends.py'
15--- u1db/tests/test_backends.py 2012-09-28 12:13:18 +0000
16+++ u1db/tests/test_backends.py 2012-10-06 16:19:20 +0000
17@@ -1859,6 +1859,9 @@
18 doc = self.db.create_doc(self.simple_doc, doc_id='my_doc_id')
19 self.assertTrue(isinstance(doc, TestAlternativeDocument))
20
21+ def test_create_doc_with_invalid_content(self):
22+ self.assertRaises(errors.InvalidContent, self.db.create_doc, "{}")
23+
24 def test_get_doc_after_put_with_factory(self):
25 doc = self.db.create_doc(self.simple_doc, doc_id='my_doc_id')
26 self.db.set_document_factory(TestAlternativeDocument)

Subscribers

People subscribed via source and target branches