summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2016-07-08 13:02:10 +0200
committerKali Kaneko <kali@leap.se>2016-07-12 03:09:31 +0200
commit42521e368734d358c3169495003fae32c28da2b1 (patch)
tree27034dfe2a0409cf3feb1756d3aa815987aa1d20
parent297ecdb24b238eff7e7674c7ab2df1f116007d7e (diff)
[test] properly close dbpool on async test
-rw-r--r--testing/tests/client/test_async.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/testing/tests/client/test_async.py b/testing/tests/client/test_async.py
index 2ff70864..42c315fe 100644
--- a/testing/tests/client/test_async.py
+++ b/testing/tests/client/test_async.py
@@ -32,6 +32,14 @@ class ASyncSQLCipherRetryTestCase(BaseSoledadTest):
NUM_DOCS = 5000
+ def setUp(self):
+ BaseSoledadTest.setUp(self)
+ self._dbpool = self._get_dbpool()
+
+ def tearDown(self):
+ self._dbpool.close()
+ BaseSoledadTest.tearDown(self)
+
def _get_dbpool(self):
tmpdb = os.path.join(self.tempdir, "test.soledad")
opts = SQLCipherOptions(tmpdb, "secret", create=True)
@@ -72,10 +80,8 @@ class ASyncSQLCipherRetryTestCase(BaseSoledadTest):
adbapi.SQLCIPHER_CONNECTION_TIMEOUT = 1
adbapi.SQLCIPHER_MAX_RETRIES = 1
- dbpool = self._get_dbpool()
-
def _create_doc(doc):
- return dbpool.runU1DBQuery("create_doc", doc)
+ return self._dbpool.runU1DBQuery("create_doc", doc)
def _insert_docs():
deferreds = []
@@ -95,7 +101,7 @@ class ASyncSQLCipherRetryTestCase(BaseSoledadTest):
raise Exception
d = _insert_docs()
- d.addCallback(lambda _: dbpool.runU1DBQuery("get_all_docs"))
+ d.addCallback(lambda _: self._dbpool.runU1DBQuery("get_all_docs"))
d.addErrback(_errback)
return d
@@ -115,10 +121,8 @@ class ASyncSQLCipherRetryTestCase(BaseSoledadTest):
above will fail and we should remove this comment from here.
"""
- dbpool = self._get_dbpool()
-
def _create_doc(doc):
- return dbpool.runU1DBQuery("create_doc", doc)
+ return self._dbpool.runU1DBQuery("create_doc", doc)
def _insert_docs():
deferreds = []
@@ -137,6 +141,6 @@ class ASyncSQLCipherRetryTestCase(BaseSoledadTest):
raise Exception
d = _insert_docs()
- d.addCallback(lambda _: dbpool.runU1DBQuery("get_all_docs"))
+ d.addCallback(lambda _: self._dbpool.runU1DBQuery("get_all_docs"))
d.addCallback(_count_docs)
return d