summaryrefslogtreecommitdiff
path: root/testing/tests
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2017-02-28 10:22:06 -0300
committerVictor Shyba <victor1984@riseup.net>2017-03-02 18:54:32 -0300
commit5af57250f2b1cd174fa75c559bac6ea179c43d09 (patch)
treecd2ab6c73f7896c1222a642645b3b14a5f767673 /testing/tests
parentd285f07b365645a0c327a8d41402d710456583b6 (diff)
[test] bugfix: actually use an empty local db in download benchmarks
We were previously not using an empty local db for download benchmark tests, so there was actually nothing to sync. This commit fixes that by adding a way to force an empty local db on soledad client instantiation.
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/benchmarks/test_sync.py2
-rw-r--r--testing/tests/conftest.py16
2 files changed, 14 insertions, 4 deletions
diff --git a/testing/tests/benchmarks/test_sync.py b/testing/tests/benchmarks/test_sync.py
index 1501d74b..ee2e2960 100644
--- a/testing/tests/benchmarks/test_sync.py
+++ b/testing/tests/benchmarks/test_sync.py
@@ -41,7 +41,7 @@ def create_download(downloads, size):
# ensures we are dealing with properly encrypted docs
def setup():
- return soledad_client()
+ return soledad_client(force_fresh_db=True)
def sync(clean_client):
return clean_client.sync()
diff --git a/testing/tests/conftest.py b/testing/tests/conftest.py
index 1d3125d5..49cc35f6 100644
--- a/testing/tests/conftest.py
+++ b/testing/tests/conftest.py
@@ -191,9 +191,19 @@ def soledad_client(tmpdir, soledad_server, remote_db, soledad_dbs, request):
soledad_dbs(default_uuid)
# get a soledad instance
- def create():
- secrets_path = os.path.join(tmpdir.strpath, '%s.secret' % default_uuid)
- local_db_path = os.path.join(tmpdir.strpath, '%s.db' % default_uuid)
+ def create(force_fresh_db=False):
+ secrets_file = '%s.secret' % default_uuid
+ secrets_path = os.path.join(tmpdir.strpath, secrets_file)
+
+ # in some tests we might want to use the same user and remote database
+ # but with a clean/empty local database (i.e. download benchmarks), so
+ # here we provide a way to do that.
+ db_file = '%s.db' % default_uuid
+ if force_fresh_db:
+ prefix = uuid4().hex
+ db_file = prefix + '-' + db_file
+ local_db_path = os.path.join(tmpdir.strpath, db_file)
+
soledad_client = Soledad(
default_uuid,
unicode(passphrase),