From 338498cef1cd4f2b9ae49bc54bd496de0e5472a0 Mon Sep 17 00:00:00 2001 From: mnandri Date: Wed, 16 Dec 2015 16:35:33 +0100 Subject: WIP: rename me later --- service/test/integration/test_retrieve_attachment.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'service/test/integration/test_retrieve_attachment.py') diff --git a/service/test/integration/test_retrieve_attachment.py b/service/test/integration/test_retrieve_attachment.py index bc7f8a0d..ca11a14d 100644 --- a/service/test/integration/test_retrieve_attachment.py +++ b/service/test/integration/test_retrieve_attachment.py @@ -13,10 +13,13 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . +import base64 +from email import encoders from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText +from poster.encode import multipart_encode, MultipartParam from twisted.internet import defer from test.support.integration.soledad_test_base import SoledadTestBase @@ -49,3 +52,17 @@ class RetrieveAttachmentTest(SoledadTestBase): self.assertEqual(404, req.code) self.assertIsNone(attachment) + + @defer.inlineCallbacks + def test_post_new_attachment(self): + content_type = 'text/plain' + filename = 'filename.txt' + data = 'pretend to be binary attachment data' + file = MultipartParam('attachment', value=data, filename=filename, filetype=content_type) + datagen, headers = multipart_encode([file]) + post_data = "".join(datagen) + + _, req = yield self.post_attachment(post_data, headers) + + self.assertEqual(201, req.code) + self.assertEqual('/attachment/B5B4ED80AC3B894523D72E375DACAA2FC6606C18EDF680FE95903086C8B5E14A', req.headers['Location']) -- cgit v1.2.3