Skip to content
Browse files

added __setitem__ handling of DesignDocs

Change-Id: I12f8a4158af4f87523de1ea4062133f743f6d367
Reviewed-on: http://review.couchbase.org/20123
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>
Tested-by: Benjamin Young <benjamin@couchbase.com>
  • Loading branch information...
1 parent 0e689e3 commit 874808d9aca6e289a4e52b750c39ba022565c444 @BigBlueHat BigBlueHat committed with BigBlueHat Aug 22, 2012
Showing with 17 additions and 0 deletions.
  1. +3 −0 couchbase/client.py
  2. +14 −0 couchbase/tests/test_client.py
View
3 couchbase/client.py
@@ -292,6 +292,9 @@ def __setitem__(self, key, value):
v = value['value']
self.set(key, value.get('expiration', 0),
value.get('flags', 0), v)
+ elif key.startswith('_design/'):
+ rest = self.server._rest()
+ rest.create_design_doc(self.name, key[8:], json.dumps(value))
else:
self.set(key, 0, 0, json.dumps(value))
else:
View
14 couchbase/tests/test_client.py
@@ -287,6 +287,20 @@ def test_design_docs(self):
for key in doc_names:
self.client.delete(key)
+ @attr(cbv="2.0.0")
+ def test_design_doc_creation_via_setitem(self):
+ design_doc = {"views":
+ {"testing":
+ {"map":
+ "function(doc) { emit(doc.name, doc.num); }"
+ }
+ }
+ }
+ self.client['_design/testing_setitem'] = design_doc
+ self.assertIn('testing_setitem', self.client.design_docs())
+ rest = self.client.server._rest()
+ rest.delete_design_doc(self.client.name, 'testing_setitem')
+
class DesignDocTest(Base):
def setUp(self):

0 comments on commit 874808d

Please sign in to comment.
Something went wrong with that request. Please try again.