diff options
author | drebs <drebs@leap.se> | 2016-10-03 19:27:42 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2016-10-03 19:27:42 -0300 |
commit | 4e06eb370b99f2d343e96f774a3ad9b8b77c9548 (patch) | |
tree | 749fd8131c31a562168978de27e7efd45b696364 /testing/tests/couch/conftest.py | |
parent | e13aefd14e82794622613802733713c6226e1d59 (diff) |
[feature] check for user dbs couch schema versions
Diffstat (limited to 'testing/tests/couch/conftest.py')
-rw-r--r-- | testing/tests/couch/conftest.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testing/tests/couch/conftest.py b/testing/tests/couch/conftest.py new file mode 100644 index 00000000..1074f091 --- /dev/null +++ b/testing/tests/couch/conftest.py @@ -0,0 +1,31 @@ +import couchdb +import pytest +import random +import string + + +@pytest.fixture +def random_name(): + return 'user-' + ''.join( + random.choice( + string.ascii_lowercase) for _ in range(10)) + + +class RandomDatabase(object): + + def __init__(self, couch_url, name): + self.couch_url = couch_url + self.name = name + self.server = couchdb.client.Server(couch_url) + self.database = self.server.create(name) + + def teardown(self): + self.server.delete(self.name) + + +@pytest.fixture +def db(random_name, request): + couch_url = request.config.getoption('--couch-url') + db = RandomDatabase(couch_url, random_name) + request.addfinalizer(db.teardown) + return db |