summaryrefslogtreecommitdiff
path: root/testing/tests
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2016-07-25 07:48:41 -0300
committerdrebs <drebs@leap.se>2016-08-01 21:09:03 -0300
commitfa2c50b9c6cc037a8ab348b5a746b2e728f3068a (patch)
tree4d73a4f8f1f7d5853194119ccbee6eca4ca7da44 /testing/tests
parentc40a2bf488e03bef14d440ab1a847afab6f5fb76 (diff)
[test] allow custom couch url for couch tests
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/conftest.py13
-rw-r--r--testing/tests/couch/common.py6
-rw-r--r--testing/tests/couch/couchdb.ini.template22
-rw-r--r--testing/tests/couch/test_backend.py5
4 files changed, 16 insertions, 30 deletions
diff --git a/testing/tests/conftest.py b/testing/tests/conftest.py
new file mode 100644
index 00000000..3be9ba2a
--- /dev/null
+++ b/testing/tests/conftest.py
@@ -0,0 +1,13 @@
+import pytest
+
+
+def pytest_addoption(parser):
+ parser.addoption(
+ "--couch-url", type="string", default="http://127.0.0.1:5984",
+ help="the url for the couch server to be used during tests")
+
+
+@pytest.fixture
+def couch_url(request):
+ url = request.config.getoption('--couch-url')
+ request.cls.couch_url = url
diff --git a/testing/tests/couch/common.py b/testing/tests/couch/common.py
index 45cf8d7f..48d30168 100644
--- a/testing/tests/couch/common.py
+++ b/testing/tests/couch/common.py
@@ -13,10 +13,9 @@ nested_doc = tests.nested_doc
def make_couch_database_for_test(test, replica_uid):
- port = str(test.couch_port)
dbname = ('test-%s' % uuid4().hex)
db = couch.CouchDatabase.open_database(
- urljoin('http://localhost:' + port, dbname),
+ urljoin(test.couch_url, dbname),
create=True,
replica_uid=replica_uid or 'test',
ensure_ddocs=True)
@@ -25,8 +24,7 @@ def make_couch_database_for_test(test, replica_uid):
def copy_couch_database_for_test(test, db):
- port = str(test.couch_port)
- couch_url = 'http://localhost:' + port
+ couch_url = test.couch_url
new_dbname = db._dbname + '_copy'
new_db = couch.CouchDatabase.open_database(
urljoin(couch_url, new_dbname),
diff --git a/testing/tests/couch/couchdb.ini.template b/testing/tests/couch/couchdb.ini.template
deleted file mode 100644
index 174d9d86..00000000
--- a/testing/tests/couch/couchdb.ini.template
+++ /dev/null
@@ -1,22 +0,0 @@
-; etc/couchdb/default.ini.tpl. Generated from default.ini.tpl.in by configure.
-
-; Upgrading CouchDB will overwrite this file.
-
-[couchdb]
-database_dir = %(tempdir)s/lib
-view_index_dir = %(tempdir)s/lib
-max_document_size = 4294967296 ; 4 GB
-os_process_timeout = 120000 ; 120 seconds. for view and external servers.
-max_dbs_open = 100
-delayed_commits = true ; set this to false to ensure an fsync before 201 Created is returned
-uri_file = %(tempdir)s/lib/couch.uri
-file_compression = snappy
-
-[log]
-file = %(tempdir)s/log/couch.log
-level = info
-include_sasl = true
-
-[httpd]
-port = 0
-bind_address = 127.0.0.1
diff --git a/testing/tests/couch/test_backend.py b/testing/tests/couch/test_backend.py
index c399338e..4fad11cf 100644
--- a/testing/tests/couch/test_backend.py
+++ b/testing/tests/couch/test_backend.py
@@ -39,10 +39,7 @@ class TestCouchBackendImpl(CouchDBTestCase):
def test__allocate_doc_id(self):
db = couch.CouchDatabase.open_database(
- urljoin(
- 'http://localhost:' + str(self.couch_port),
- ('test-%s' % uuid4().hex)
- ),
+ urljoin(self.couch_url, 'test-%s' % uuid4().hex),
create=True)
doc_id1 = db._allocate_doc_id()
self.assertTrue(doc_id1.startswith('D-'))