summaryrefslogtreecommitdiff
path: root/testing/tests/blobs/test_blob_manager.py
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-09-07 18:09:11 -0300
committerdrebs <drebs@riseup.net>2017-09-11 11:22:59 -0300
commitf5e2ec7f1901863ce967a91cf0a244b771bcf857 (patch)
tree1df7334734c25a81bf5e368779bcfcd5d91f9afe /testing/tests/blobs/test_blob_manager.py
parentf0e069b9f7f0718263d96b3158c0c6a3de959d04 (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_blob_manager.py')
-rw-r--r--testing/tests/blobs/test_blob_manager.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/testing/tests/blobs/test_blob_manager.py b/testing/tests/blobs/test_blob_manager.py
index dd57047d..7d985768 100644
--- a/testing/tests/blobs/test_blob_manager.py
+++ b/testing/tests/blobs/test_blob_manager.py
@@ -42,17 +42,17 @@ class BlobManagerTestCase(unittest.TestCase):
self.manager = BlobManager(
self.tempdir, '',
'A' * 32, self.secret,
- 'uuid', 'token', None)
+ uuid4().hex, 'token', None)
self.addCleanup(self.manager.close)
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
- def test_get_inexistent(self):
+ def test_get_missing(self):
self.manager._download_and_decrypt = Mock(return_value=None)
- bad_blob_id = 'inexsistent_id'
- result = yield self.manager.get(bad_blob_id)
+ missing_blob_id = uuid4().hex
+ result = yield self.manager.get(missing_blob_id)
self.assertIsNone(result)
- args = bad_blob_id, ''
+ args = missing_blob_id, ''
self.manager._download_and_decrypt.assert_called_once_with(*args)
@defer.inlineCallbacks
@@ -109,26 +109,26 @@ class BlobManagerTestCase(unittest.TestCase):
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
def test_send_missing(self):
- fd = BytesIO('test')
+ fd, missing_id = BytesIO('test'), uuid4().hex
self.manager._encrypt_and_upload = Mock(return_value=None)
self.manager.remote_list = Mock(return_value=[])
- yield self.manager.local.put('missing_id', fd, 4)
+ yield self.manager.local.put(missing_id, fd, 4)
yield self.manager.send_missing()
call_list = self.manager._encrypt_and_upload.call_args_list
self.assertEquals(1, len(call_list))
call_blob_id, call_fd = call_list[0][0]
- self.assertEquals('missing_id', call_blob_id)
+ self.assertEquals(missing_id, call_blob_id)
self.assertEquals('test', call_fd.getvalue())
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
def test_duplicated_blob_error_on_put(self):
self.manager._encrypt_and_upload = Mock(return_value=None)
- content = "Blob content"
- doc1 = BlobDoc(BytesIO(content), 'existing_id')
+ content, existing_id = "Blob content", uuid4().hex
+ doc1 = BlobDoc(BytesIO(content), existing_id)
yield self.manager.put(doc1, len(content))
- doc2 = BlobDoc(BytesIO(content), 'existing_id')
+ doc2 = BlobDoc(BytesIO(content), existing_id)
self.manager._encrypt_and_upload.reset_mock()
with pytest.raises(BlobAlreadyExistsError):
yield self.manager.put(doc2, len(content))