From c7b464077215425759ab402fb2314f4e8f9acd7e Mon Sep 17 00:00:00 2001 From: drebs Date: Sat, 23 Jul 2016 17:11:53 +0200 Subject: [test] remove traces of design docs from couch tests --- testing/test_soledad/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index 033a55df..02f3859b 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -391,8 +391,7 @@ class CouchServerStateForTests(CouchServerState): db = CouchDatabase.open_database( urljoin(self.couch_url, dbname), True, - replica_uid=replica_uid or 'test', - ensure_ddocs=True) + replica_uid=replica_uid or 'test') self.dbs.append(db) return db -- cgit v1.2.3 From fa2c50b9c6cc037a8ab348b5a746b2e728f3068a Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 25 Jul 2016 07:48:41 -0300 Subject: [test] allow custom couch url for couch tests --- testing/test_soledad/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index 02f3859b..e23d185e 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -27,6 +27,7 @@ import shutil import random import string import couchdb +import pytest from uuid import uuid4 from mock import Mock @@ -344,6 +345,7 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): self.assertEqual(exp_doc.content, doc.content) +@pytest.mark.usefixtures("couch_url") class CouchDBTestCase(unittest.TestCase, MockedSharedDBTest): """ @@ -354,8 +356,6 @@ class CouchDBTestCase(unittest.TestCase, MockedSharedDBTest): """ Make sure we have a CouchDB instance for a test. """ - self.couch_port = 5984 - self.couch_url = 'http://localhost:%d' % self.couch_port self.couch_server = couchdb.Server(self.couch_url) def delete_db(self, name): -- cgit v1.2.3 From d5bbe37495ee733be5f78de72364f3ec48ed7a0d Mon Sep 17 00:00:00 2001 From: drebs Date: Sat, 24 Sep 2016 11:32:13 -0300 Subject: [test] use pytest tmpdir fixture in all tests Tests that were imported from u1db or created on top of that structure were leaving temporary directories behind. This could cause problems in test servers, either by filling the partition or by extrapolating the maximum amount of files in a directory. This commit replaces all usages of temporary directories in the old test structure by pytest tmpdir fixture, which properly cares for removing temporary directories. --- testing/test_soledad/util.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'testing/test_soledad/util.py') diff --git a/testing/test_soledad/util.py b/testing/test_soledad/util.py index e23d185e..d53f6cda 100644 --- a/testing/test_soledad/util.py +++ b/testing/test_soledad/util.py @@ -22,8 +22,6 @@ Utilities used by multiple test suites. import os -import tempfile -import shutil import random import string import couchdb @@ -43,7 +41,6 @@ from leap.soledad.common import l2db from leap.soledad.common.l2db import sync from leap.soledad.common.l2db.remote import http_database -from leap.soledad.common import soledad_assert from leap.soledad.common.document import SoledadDocument from leap.soledad.common.couch import CouchDatabase from leap.soledad.common.couch.state import CouchServerState @@ -226,6 +223,7 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): """ defer_sync_encryption = False + @pytest.mark.usefixtures("method_tmpdir") def setUp(self): # The following snippet comes from BaseLeapTest.setUpClass, but we # repeat it here because twisted.trial does not work with @@ -233,7 +231,6 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): self.old_path = os.environ['PATH'] self.old_home = os.environ['HOME'] - self.tempdir = tempfile.mkdtemp(prefix="leap_tests-") self.home = self.tempdir bin_tdir = os.path.join( self.tempdir, @@ -276,14 +273,6 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest): self._soledad.secrets.secrets_path]: if os.path.isfile(f): os.unlink(f) - # The following snippet comes from BaseLeapTest.setUpClass, but we - # repeat it here because twisted.trial does not work with - # setUpClass/tearDownClass. - soledad_assert( - self.tempdir.startswith('/tmp/leap_tests-'), - "beware! tried to remove a dir which does not " - "live in temporal folder!") - shutil.rmtree(self.tempdir) from twisted.internet import reactor reactor.addSystemEventTrigger( -- cgit v1.2.3