summaryrefslogtreecommitdiff
path: root/common/src/leap/soledad/common/tests/test_couch.py
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/leap/soledad/common/tests/test_couch.py')
-rw-r--r--common/src/leap/soledad/common/tests/test_couch.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/common/src/leap/soledad/common/tests/test_couch.py b/common/src/leap/soledad/common/tests/test_couch.py
index 17d4a519..3b1e5a06 100644
--- a/common/src/leap/soledad/common/tests/test_couch.py
+++ b/common/src/leap/soledad/common/tests/test_couch.py
@@ -219,7 +219,6 @@ def copy_couch_database_for_test(test, db):
new_couch_db.put_attachment(new_doc, att,
filename=att_name)
# cleanup connections to prevent file descriptor leaking
- session.close_connections()
return new_db
@@ -249,13 +248,10 @@ class CouchTests(test_backends.AllDatabaseTests, CouchDBTestCase):
# if current test is `test_close` we have to use saved objects to
# delete the database because the close() method will have removed the
# references needed to do it using the CouchDatabase.
- if self.id() == \
- 'leap.soledad.common.tests.test_couch.CouchTests.' \
- 'test_close(couch)':
+ if self.id().endswith('test_couch.CouchTests.test_close(couch)'):
session = couch.Session()
server = Server(url=self._url, session=session)
del(server[self._dbname])
- session.close_connections()
else:
self.db.delete_database()
test_backends.AllDatabaseTests.tearDown(self)
@@ -365,8 +361,6 @@ class CouchDatabaseSyncTargetTests(test_sync.DatabaseSyncTargetTests,
# The following tests need that the database have an index, so we fake one.
-old_class = couch.CouchDatabase
-
from u1db.backends.inmemory import InMemoryIndex
@@ -444,7 +438,12 @@ class IndexedCouchDatabase(couch.CouchDatabase):
return list(set([tuple(key.split('\x01')) for key in keys]))
-couch.CouchDatabase = IndexedCouchDatabase
+# monkey patch CouchDatabase (once) to include virtual indexes
+if getattr(couch.CouchDatabase, '_old_class', None) is None:
+ old_class = couch.CouchDatabase
+ IndexedCouchDatabase._old_class = old_class
+ couch.CouchDatabase = IndexedCouchDatabase
+
sync_scenarios = []
for name, scenario in COUCH_SCENARIOS: