summaryrefslogtreecommitdiff
path: root/service/test/unit/resources
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2015-12-21 10:44:37 +0100
committerNavaL <mnandri@thoughtworks.com>2015-12-21 11:00:14 +0100
commit651568ff85bde4aa152ba18eed8b587f4f2f3cab (patch)
tree732b92a3de4bf74ac710d314b7e622a60f94b04e /service/test/unit/resources
parent4e7679766932e3d29914607f0db64ef8613b22b7 (diff)
added filename and size to the attachment endpoint post response
Issue #548
Diffstat (limited to 'service/test/unit/resources')
-rw-r--r--service/test/unit/resources/test_attachments_resource.py5
-rw-r--r--service/test/unit/resources/test_mails_resource.py9
2 files changed, 9 insertions, 5 deletions
diff --git a/service/test/unit/resources/test_attachments_resource.py b/service/test/unit/resources/test_attachments_resource.py
index 2afa208c..c44dab84 100644
--- a/service/test/unit/resources/test_attachments_resource.py
+++ b/service/test/unit/resources/test_attachments_resource.py
@@ -27,6 +27,7 @@ class AttachmentsResourceTest(unittest.TestCase):
_file = MagicMock()
_file.value = 'some mocked value'
_file.type = 'some mocked type'
+ _file.filename = 'filename.txt'
mock_fields.return_value = {'attachment': _file}
when(self.mail_service).save_attachment('some mocked value', 'some mocked type').thenReturn(defer.succeed(attachment_id))
@@ -35,7 +36,9 @@ class AttachmentsResourceTest(unittest.TestCase):
def assert_response(_):
self.assertEqual(201, request.code)
self.assertEqual('/attachment/%s' % attachment_id, request.headers['Location'])
- self.assertEqual({'attachment_id': attachment_id}, json.loads(request.written[0]))
+ response_json = {'attachment_id': attachment_id, 'content-type': 'some mocked type',
+ 'filename': 'filename.txt', 'filesize': 17}
+ self.assertEqual(response_json, json.loads(request.written[0]))
verify(self.mail_service).save_attachment('some mocked value', 'some mocked type')
d.addCallback(assert_response)
diff --git a/service/test/unit/resources/test_mails_resource.py b/service/test/unit/resources/test_mails_resource.py
index 44aebd4d..76fe8bb3 100644
--- a/service/test/unit/resources/test_mails_resource.py
+++ b/service/test/unit/resources/test_mails_resource.py
@@ -15,13 +15,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import unittest
-import json
+
+from mock import patch
from mockito import mock, when, verify
-from test.unit.resources import DummySite
+from twisted.internet import defer
from twisted.web.test.requesthelper import DummyRequest
+
from pixelated.resources.mails_resource import MailsResource
-from twisted.internet import defer
-from mock import patch
+from test.unit.resources import DummySite
class TestMailsResource(unittest.TestCase):