diff options
author | drebs <drebs@leap.se> | 2017-12-06 20:29:44 -0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-12-13 13:43:48 -0200 |
commit | 8f94f9c2d93046e0f67cffd7974f7d28393bbf86 (patch) | |
tree | 0c6bc388462a6564fc6f0fbf494dc0c723aab50f /tests | |
parent | 4a6ea1ac3302420584a3cd453652e487c5eebca0 (diff) |
[refactor] make blobs backend write_blob() agnostic of twisted.web requests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/blobs/test_fs_backend.py | 16 | ||||
-rw-r--r-- | tests/server/test_incoming_server.py | 5 |
2 files changed, 9 insertions, 12 deletions
diff --git a/tests/blobs/test_fs_backend.py b/tests/blobs/test_fs_backend.py index 58d8690d..5a136f00 100644 --- a/tests/blobs/test_fs_backend.py +++ b/tests/blobs/test_fs_backend.py @@ -82,10 +82,9 @@ class FilesystemBackendTestCase(unittest.TestCase): def test_cannot_overwrite(self, isfile): isfile.return_value = True backend = _blobs.FilesystemBlobsBackend(blobs_path=self.tempdir) - request = DummyRequest(['']) - yield backend.write_blob('user', 'blob_id', request) - self.assertEquals(request.written[0], "Blob already exists: blob_id") - self.assertEquals(request.responseCode, 409) + with pytest.raises(_blobs.BlobExists): + fd = Mock() + yield backend.write_blob('user', 'blob_id', fd) @pytest.mark.usefixtures("method_tmpdir") @mock.patch.object(os.path, 'isfile') @@ -93,14 +92,11 @@ class FilesystemBackendTestCase(unittest.TestCase): def test_write_cannot_exceed_quota(self, isfile): isfile.return_value = False backend = _blobs.FilesystemBlobsBackend(blobs_path=self.tempdir) - request = Mock() - backend.get_total_storage = lambda x: 100 backend.quota = 90 - yield backend.write_blob('user', 'blob_id', request) - - request.setResponseCode.assert_called_once_with(507) - request.write.assert_called_once_with('Quota Exceeded!') + with pytest.raises(_blobs.QuotaExceeded): + fd = Mock() + yield backend.write_blob('user', 'blob_id', fd) @pytest.mark.usefixtures("method_tmpdir") def test_get_path_partitioning_by_default(self): diff --git a/tests/server/test_incoming_server.py b/tests/server/test_incoming_server.py index 42637c87..d5127077 100644 --- a/tests/server/test_incoming_server.py +++ b/tests/server/test_incoming_server.py @@ -84,8 +84,9 @@ class IncomingOnCouchServerTestCase(CouchDBTestCase): db = self.state.open_database(user_id) request = DummyRequest([user_id, doc_id]) - yield db.read_blob(user_id, doc_id, request, 'MX') - flags = db.get_flags(user_id, doc_id, 'MX') + res = db.read_blob(user_id, doc_id, namespace='MX') + yield res.render_GET(request) + flags = db.get_flags(user_id, doc_id, namespace='MX') expected_preamble = formatter.preamble(content, doc_id) expected_preamble = decode_preamble(expected_preamble, True) written_preamble, written_content = request.written[0].split() |