summaryrefslogtreecommitdiff
path: root/testing/tests/server/test_incoming_resource.py
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-06-10 06:19:03 -0300
committerVictor Shyba <victor1984@riseup.net>2017-07-02 01:32:39 -0300
commitcbcc049737e26e30db8890e31d6b98725bdb3385 (patch)
treeccbd776729c2971da5764116d4ef2169b40fc4d4 /testing/tests/server/test_incoming_resource.py
parent7ef11157c9af8dcddbc52f063f8f362bddc6c36f (diff)
[feature] add formatting from MX into incoming
Use the same formatting as MX was using for backwards compatibility. -- Resolves: #8828
Diffstat (limited to 'testing/tests/server/test_incoming_resource.py')
-rw-r--r--testing/tests/server/test_incoming_resource.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/testing/tests/server/test_incoming_resource.py b/testing/tests/server/test_incoming_resource.py
index ccec2198..81925580 100644
--- a/testing/tests/server/test_incoming_resource.py
+++ b/testing/tests/server/test_incoming_resource.py
@@ -20,6 +20,8 @@ Unit tests for incoming API resource
from twisted.trial import unittest
from twisted.web.test.test_web import DummyRequest
from leap.soledad.server._incoming import IncomingResource
+from leap.soledad.server._incoming import IncomingFormatter
+from leap.soledad.common.crypto import EncryptionSchemes
from io import BytesIO
from uuid import uuid4
from mock import Mock
@@ -35,9 +37,11 @@ class BlobServerTestCase(unittest.TestCase):
self.user_uuid = uuid4().hex
def test_save_document(self):
- doc_id = uuid4().hex
- request = DummyRequest([self.user_uuid, doc_id])
- request.content = BytesIO('{}')
+ formatter = IncomingFormatter()
+ doc_id, scheme = uuid4().hex, EncryptionSchemes.NONE
+ content = 'Incoming content'
+ request = DummyRequest([self.user_uuid, doc_id, scheme])
+ request.content = BytesIO(content)
self.resource.render_PUT(request)
open_database = self.backend_factory.open_database
@@ -45,4 +49,4 @@ class BlobServerTestCase(unittest.TestCase):
self.couchdb.put_doc.assert_called_once()
doc = self.couchdb.put_doc.call_args[0][0]
self.assertEquals(doc_id, doc.doc_id)
- self.assertEquals('{}', doc.get_json())
+ self.assertEquals(formatter.format(content, scheme), doc.content)