summaryrefslogtreecommitdiff
path: root/service/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'service/test/unit')
-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):