diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-09-07 18:09:11 -0300 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2017-09-11 11:22:59 -0300 |
commit | f5e2ec7f1901863ce967a91cf0a244b771bcf857 (patch) | |
tree | 1df7334734c25a81bf5e368779bcfcd5d91f9afe /testing/tests/blobs/test_sqlcipher_client_backend.py | |
parent | f0e069b9f7f0718263d96b3158c0c6a3de959d04 (diff) |
[tests] improve isolation on user uuid
Hardcoded and repeated user uuids can lead to accidental concurrent
operations between test cases, breaking isolation and creating random
failures. This commit improves it a bit.
Diffstat (limited to 'testing/tests/blobs/test_sqlcipher_client_backend.py')
-rw-r--r-- | testing/tests/blobs/test_sqlcipher_client_backend.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/testing/tests/blobs/test_sqlcipher_client_backend.py b/testing/tests/blobs/test_sqlcipher_client_backend.py index 6193b486..daf561c7 100644 --- a/testing/tests/blobs/test_sqlcipher_client_backend.py +++ b/testing/tests/blobs/test_sqlcipher_client_backend.py @@ -21,6 +21,7 @@ from twisted.trial import unittest from twisted.internet import defer from leap.soledad.client._db.blobs import SQLiteBlobBackend from io import BytesIO +from uuid import uuid4 import pytest @@ -34,7 +35,7 @@ class SQLBackendTestCase(unittest.TestCase): @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") def test_get_inexisting(self): - bad_blob_id = 'inexsisting_id' + bad_blob_id = uuid4().hex self.assertFalse((yield self.local.exists(bad_blob_id))) result = yield self.local.get(bad_blob_id) self.assertIsNone(result) @@ -42,7 +43,7 @@ class SQLBackendTestCase(unittest.TestCase): @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") def test_get_existing(self): - blob_id = 'blob_id' + blob_id = uuid4().hex content = "x" yield self.local.put(blob_id, BytesIO(content), len(content)) result = yield self.local.get(blob_id) @@ -52,18 +53,18 @@ class SQLBackendTestCase(unittest.TestCase): @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") def test_delete(self): - blob_id = 'blob_id' + blob_id1, blob_id2 = uuid4().hex, uuid4().hex content = "x" - yield self.local.put(blob_id, BytesIO(content), len(content)) - yield self.local.put('remains', BytesIO(content), len(content)) - yield self.local.delete(blob_id) - self.assertFalse((yield self.local.exists(blob_id))) - self.assertTrue((yield self.local.exists('remains'))) + yield self.local.put(blob_id1, BytesIO(content), len(content)) + yield self.local.put(blob_id2, BytesIO(content), len(content)) + yield self.local.delete(blob_id1) + self.assertFalse((yield self.local.exists(blob_id1))) + self.assertTrue((yield self.local.exists(blob_id2))) @defer.inlineCallbacks @pytest.mark.usefixtures("method_tmpdir") def test_list(self): - blob_ids = [('blob_id%s' % i) for i in range(10)] + blob_ids = [uuid4().hex for _ in range(10)] content = "x" deferreds = [] for blob_id in blob_ids: |