summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-03-30 18:08:09 -0300
committerdrebs <drebs@leap.se>2017-04-04 18:27:40 +0200
commit414ecfbb95b067d8f72400af4da9ed686742efc3 (patch)
tree0bd768d3b4e46a16457d7f4855dc4aaae97a6692 /testing
parent5202f9f850501aeec2289416147a49706e86be1f (diff)
[test] change assert for self.assertX
Diffstat (limited to 'testing')
-rw-r--r--testing/tests/blobs/test_blobs.py4
-rw-r--r--testing/tests/blobs/test_fs_backend.py8
-rw-r--r--testing/tests/blobs/test_local_backend.py18
-rw-r--r--testing/tests/server/test_blobs_server.py5
4 files changed, 17 insertions, 18 deletions
diff --git a/testing/tests/blobs/test_blobs.py b/testing/tests/blobs/test_blobs.py
index ecb180f1..8dd3abbe 100644
--- a/testing/tests/blobs/test_blobs.py
+++ b/testing/tests/blobs/test_blobs.py
@@ -47,7 +47,7 @@ class BlobTestCase(unittest.TestCase):
buf = DecrypterBuffer(doc_id, rev, self.secret, tag)
buf.write(encrypted)
fd, size = buf.close()
- assert fd.getvalue() == 'rosa de foc'
+ self.assertEquals(fd.getvalue(), 'rosa de foc')
@defer.inlineCallbacks
def test_blob_manager_encrypted_upload(self):
@@ -59,7 +59,7 @@ class BlobTestCase(unittest.TestCase):
armor=False,
secret=self.secret)
decrypted = yield decryptor.decrypt()
- assert decrypted.getvalue() == 'up and up'
+ self.assertEquals(decrypted.getvalue(), 'up and up')
defer.returnValue(Mock(code=200))
manager = BlobManager('', '', self.secret, self.secret, 'user')
diff --git a/testing/tests/blobs/test_fs_backend.py b/testing/tests/blobs/test_fs_backend.py
index a2a374c6..78878063 100644
--- a/testing/tests/blobs/test_fs_backend.py
+++ b/testing/tests/blobs/test_fs_backend.py
@@ -63,8 +63,8 @@ class FilesystemBackendTestCase(unittest.TestCase):
backend._get_path = Mock(return_value='path')
request = DummyRequest([''])
result = backend.write_blob('user', 'blob_id', request)
- assert result == "Blob already exists: blob_id"
- assert request.responseCode == 409
+ self.assertEquals(result, "Blob already exists: blob_id")
+ self.assertEquals(request.responseCode, 409)
@pytest.mark.usefixtures("method_tmpdir")
@mock.patch.object(os.path, 'isfile')
@@ -86,7 +86,7 @@ class FilesystemBackendTestCase(unittest.TestCase):
backend = _blobs.FilesystemBlobsBackend()
backend.path = '/somewhere/'
path = backend._get_path('user', 'blob_id')
- assert path == '/somewhere/user/b/blo/blob_i/blob_id'
+ self.assertEquals(path, '/somewhere/user/b/blo/blob_i/blob_id')
@pytest.mark.usefixtures("method_tmpdir")
@mock.patch('leap.soledad.server._blobs.os.walk')
@@ -94,4 +94,4 @@ class FilesystemBackendTestCase(unittest.TestCase):
backend, _ = _blobs.FilesystemBlobsBackend(self.tempdir), None
walk_mock.return_value = [(_, _, ['blob_0']), (_, _, ['blob_1'])]
result = json.loads(backend.list_blobs('user', DummyRequest([''])))
- assert result == ['blob_0', 'blob_1']
+ self.assertEquals(result, ['blob_0', 'blob_1'])
diff --git a/testing/tests/blobs/test_local_backend.py b/testing/tests/blobs/test_local_backend.py
index 9dd5bb04..80696553 100644
--- a/testing/tests/blobs/test_local_backend.py
+++ b/testing/tests/blobs/test_local_backend.py
@@ -47,7 +47,7 @@ class BlobManagerTestCase(unittest.TestCase):
self.manager._download_and_decrypt = Mock(return_value=None)
args = ('inexistent_blob_id', 'inexistent_doc_id', 'inexistent_rev')
result = yield self.manager.get(*args)
- assert result is None
+ self.assertIsNone(result)
self.manager._download_and_decrypt.assert_called_once_with(*args)
@defer.inlineCallbacks
@@ -59,8 +59,8 @@ class BlobManagerTestCase(unittest.TestCase):
size=len(msg))
args = ('myblob_id', 'mydoc_id', 'cool_rev')
result = yield self.manager.get(*args)
- assert result.getvalue() == msg
- assert not self.manager._download_and_decrypt.called
+ self.assertEquals(result.getvalue(), msg)
+ self.assertNot(self.manager._download_and_decrypt.called)
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
@@ -71,8 +71,8 @@ class BlobManagerTestCase(unittest.TestCase):
blob_id='myblob_id')
yield self.manager.put(doc, size=len(msg))
result = yield self.manager.local.get('myblob_id')
- assert result.getvalue() == msg
- assert self.manager._encrypt_and_upload.called
+ self.assertEquals(result.getvalue(), msg)
+ self.assertTrue(self.manager._encrypt_and_upload.called)
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
@@ -87,9 +87,9 @@ class BlobManagerTestCase(unittest.TestCase):
blob_id='myblob_id')
yield self.manager.put(doc, size=len(msg))
result = yield self.manager.get(doc.blob_id, doc.doc_id, doc.rev)
- assert result.getvalue() == msg
- assert self.manager._encrypt_and_upload.called
- assert not self.manager._download_and_decrypt.called
+ self.assertEquals(result.getvalue(), msg)
+ self.assertTrue(self.manager._encrypt_and_upload.called)
+ self.assertFalse(self.manager._download_and_decrypt.called)
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
@@ -104,4 +104,4 @@ class BlobManagerTestCase(unittest.TestCase):
yield self.manager.put(doc2, size=len(msg))
blobs_list = yield self.manager.local_list()
- assert 'myblob_id' in blobs_list and 'myblob_id2' in blobs_list
+ self.assertEquals(set(['myblob_id', 'myblob_id2']), set(blobs_list))
diff --git a/testing/tests/server/test_blobs_server.py b/testing/tests/server/test_blobs_server.py
index 22ecb3cd..96037ea2 100644
--- a/testing/tests/server/test_blobs_server.py
+++ b/testing/tests/server/test_blobs_server.py
@@ -49,7 +49,7 @@ class BlobServerTestCase(unittest.TestCase):
yield manager._encrypt_and_upload('blob_id', 'mydoc', '1', fd)
blob, size = yield manager._download_and_decrypt('blob_id',
'mydoc', '1')
- assert blob.getvalue() == "save me"
+ self.assertEquals(blob.getvalue(), "save me")
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")
@@ -59,8 +59,7 @@ class BlobServerTestCase(unittest.TestCase):
yield manager._encrypt_and_upload('blob_id1', '1', '1', BytesIO("1"))
yield manager._encrypt_and_upload('blob_id2', '2', '2', BytesIO("2"))
blobs_list = yield manager.remote_list()
- assert len(blobs_list) == 2
- assert 'blob_id1' in blobs_list and 'blob_id2' in blobs_list
+ self.assertEquals(set(['blob_id1', 'blob_id2']), set(blobs_list))
@defer.inlineCallbacks
@pytest.mark.usefixtures("method_tmpdir")