Add bulk delete testcase Fixes COUCHDB-2651
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/9642daa3 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/9642daa3 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/9642daa3 Branch: refs/heads/2651-delete-bulk-docs Commit: 9642daa37231992559dcd7f58f16cda3a4520180 Parents: de9346e Author: Tony Sun <tony....@cloudant.com> Authored: Wed Apr 1 15:37:01 2015 -0700 Committer: Tony Sun <tony....@cloudant.com> Committed: Wed Apr 1 15:37:01 2015 -0700 ---------------------------------------------------------------------- test/01-index-crud-test.py | 20 ++++++++++++++++++++ test/mango.py | 8 ++++++++ 2 files changed, 28 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/9642daa3/test/01-index-crud-test.py ---------------------------------------------------------------------- diff --git a/test/01-index-crud-test.py b/test/01-index-crud-test.py index 459566b..dde6dbb 100644 --- a/test/01-index-crud-test.py +++ b/test/01-index-crud-test.py @@ -150,6 +150,26 @@ class IndexCrudTests(mango.DbPerClass): post_indexes = self.db.list_indexes() assert pre_indexes == post_indexes + def test_bulk_delete(self): + fields = ["field1"] + ret = self.db.create_index(fields, name="idx_01") + assert ret is True + + fields = ["field2"] + ret = self.db.create_index(fields, name="idx_02") + assert ret is True + + fields = ["field3"] + ret = self.db.create_index(fields, name="idx_03") + assert ret is True + + ret = self.db.bulk_delete() + assert ret is True + + for idx in self.db.list_indexes(): + assert idx["type"] != "json" + assert idx["type"] != "text" + def test_recreate_index(self): pre_indexes = self.db.list_indexes() for i in range(5): http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/9642daa3/test/mango.py ---------------------------------------------------------------------- diff --git a/test/mango.py b/test/mango.py index 57dfffb..a59cc12 100644 --- a/test/mango.py +++ b/test/mango.py @@ -135,6 +135,14 @@ class Database(object): r = self.sess.delete(self.path(path), params={"w":"3"}) r.raise_for_status() + def bulk_delete(self): + body = { + "w": 3 + } + body = json.dumps(body) + r = self.sess.post(self.path("_index/_bulk_delete"), data=body) + return r.json()["result"] == "Indexes Deleted" + def find(self, selector, limit=25, skip=0, sort=None, fields=None, r=1, conflicts=False, use_index=None, explain=False, bookmark=None, return_raw=False):