summaryrefslogtreecommitdiff
path: root/testing/tests/perf/test_sync.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2016-07-24 07:56:52 -0300
committerdrebs <drebs@leap.se>2016-08-01 21:09:03 -0300
commit793180533e4f19b364145c61939d6cad07dd851a (patch)
treec11d84b9a3f91ab4f8189a4c513e082555fd113c /testing/tests/perf/test_sync.py
parent1893611393a3ec69d8099a8601fb21262e5f36f4 (diff)
[test] add pytest initial setup for performance tests
Diffstat (limited to 'testing/tests/perf/test_sync.py')
-rw-r--r--testing/tests/perf/test_sync.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/tests/perf/test_sync.py b/testing/tests/perf/test_sync.py
new file mode 100644
index 00000000..1e29a86a
--- /dev/null
+++ b/testing/tests/perf/test_sync.py
@@ -0,0 +1,43 @@
+import pytest
+
+from twisted.internet.defer import gatherResults
+
+from leap.soledad.common.couch import CouchDatabase
+from leap.soledad.common.document import ServerDocument
+
+
+@pytest.inlineCallbacks
+def test_upload(soledad_client):
+ # create a bunch of local documents
+ uploads = 100
+ deferreds = []
+ for i in xrange(uploads):
+ d = soledad_client.create_doc({'upload': True})
+ deferreds.append(d)
+ yield gatherResults(deferreds)
+
+ # synchronize
+ yield soledad_client.sync()
+
+ # check that documents reached the remote database
+ remote = CouchDatabase('http://127.0.0.1:5984', 'user-0')
+ remote_count, _ = remote.get_all_docs()
+ assert remote_count == uploads
+
+
+@pytest.inlineCallbacks
+def test_download(soledad_client):
+ # create a bunch of remote documents
+ downloads = 100
+ remote = CouchDatabase('http://127.0.0.1:5984', 'user-0')
+ for i in xrange(downloads):
+ doc = ServerDocument('doc-%d' % i, 'replica:1')
+ doc.content = {'download': True}
+ remote.save_document(None, doc, i)
+
+ # synchronize
+ yield soledad_client.sync()
+
+ # check that documents reached the local database
+ local_count, docs = yield soledad_client.get_all_docs()
+ assert local_count == downloads