diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-09-17 19:40:49 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-09-17 19:40:49 -0300 |
commit | 5b0e854096f35655037f4da07031741087155a7d (patch) | |
tree | d4a9c1abee0c0ca316abda3432d251e56cee4af2 | |
parent | ca7f6737e03143ae80add83d41860246f5459eae (diff) |
[tests] test for ensure ddocs independently
This tests the previous fix on ensuring a db that is missing a doc other
than 'docs'.
-rw-r--r-- | common/src/leap/soledad/common/tests/test_couch.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/common/src/leap/soledad/common/tests/test_couch.py b/common/src/leap/soledad/common/tests/test_couch.py index 845f1602..a08ffd16 100644 --- a/common/src/leap/soledad/common/tests/test_couch.py +++ b/common/src/leap/soledad/common/tests/test_couch.py @@ -1320,8 +1320,9 @@ class CouchDatabaseExceptionsTests(CouchDBTestCase): def setUp(self): CouchDBTestCase.setUp(self) - def create_db(self, ensure=True): - dbname = ('test-%s' % uuid4().hex) + def create_db(self, ensure=True, dbname=None): + if not dbname: + dbname = ('test-%s' % uuid4().hex) self.db = couch.CouchDatabase.open_database( urljoin('http://127.0.0.1:%d' % self.couch_port, dbname), create=True, @@ -1492,3 +1493,16 @@ class CouchDatabaseExceptionsTests(CouchDBTestCase): self.assertRaises( errors.MissingDesignDocDeletedError, self.db._do_set_replica_gen_and_trans_id, 1, 2, 3) + + def test_ensure_ddoc_independently(self): + """ + Test that a missing ddocs other than _design/docs will be ensured + even if _design/docs is there. + """ + self.create_db(ensure=True) + del self.db._database['_design/transactions'] + self.assertRaises( + errors.MissingDesignDocDeletedError, + self.db._get_transaction_log) + self.create_db(ensure=True, dbname=self.db._dbname) + self.db._get_transaction_log() |