diff options
Diffstat (limited to 'service')
| -rw-r--r-- | service/pixelated/resources/mail_resource.py | 2 | ||||
| -rw-r--r-- | service/test/integration/test_tags.py | 10 | ||||
| -rw-r--r-- | service/test/support/integration/app_test_client.py | 2 | ||||
| -rw-r--r-- | service/test/support/integration/soledad_test_base.py | 10 | 
4 files changed, 16 insertions, 8 deletions
| diff --git a/service/pixelated/resources/mail_resource.py b/service/pixelated/resources/mail_resource.py index 03873ffb..396ccd74 100644 --- a/service/pixelated/resources/mail_resource.py +++ b/service/pixelated/resources/mail_resource.py @@ -15,7 +15,7 @@ class MailTags(Resource):      def render_POST(self, request):          content_dict = json.loads(request.content.read()) -        new_tags = map(lambda tag: tag.lower(), content_dict['newtags']) +        new_tags = [x.lower() for x in content_dict['newtags'] if x != '']          try:              self._mail_service.update_tags(self._mail_id, new_tags)              mail = self._mail_service.mail(self._mail_id) diff --git a/service/test/integration/test_tags.py b/service/test/integration/test_tags.py index 6072392c..b32e89c7 100644 --- a/service/test/integration/test_tags.py +++ b/service/test/integration/test_tags.py @@ -42,6 +42,16 @@ class TagsTest(SoledadTestBase):          mails = self.get_mails_by_tag('important')          self.assertEquals('Mail with tags', mails[0].subject) +    def test_empty_tags_are_not_allowed(self): +        mail = MailBuilder().with_subject('Mail with tags').build_input_mail() +        self.client.add_mail_to_inbox(mail) + +        self.post_tags(mail.ident, self._tags_json(['tag1', ''])) + +        mail = self.get_mail(mail.ident) + +        self.assertEquals(mail['tags'], ['tag1']) +      def test_addition_of_reserved_tags_is_not_allowed(self):          mail = MailBuilder().with_subject('Mail with tags').build_input_mail()          self.client.add_mail_to_inbox(mail) diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 860b9c40..e8f79d2b 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -106,7 +106,7 @@ class AppTestClient:          time.sleep(1)          return lambda: process.terminate() -    def get(self, path, get_args, as_json=True): +    def get(self, path, get_args='', as_json=True):          request = request_mock(path)          request.args = get_args          return self._render(request, as_json) diff --git a/service/test/support/integration/soledad_test_base.py b/service/test/support/integration/soledad_test_base.py index 5892de60..f7693ad4 100644 --- a/service/test/support/integration/soledad_test_base.py +++ b/service/test/support/integration/soledad_test_base.py @@ -25,12 +25,6 @@ class SoledadTestBase(unittest.TestCase):      DEFERRED_TIMEOUT = 120      DEFERRED_TIMEOUT_LONG = 300 -    @classmethod -    def setUpClass(cls): -        from nose.twistedtools import threaded_reactor - -        threaded_reactor() -      def setUp(self):          self.client = AppTestClient() @@ -66,6 +60,10 @@ class SoledadTestBase(unittest.TestCase):          res, req = self.client.get('/tags', kwargs)          return res +    def get_mail(self, mail_ident): +        res, req = self.client.get('/mail/%s' % mail_ident) +        return res +      def delete_mail(self, mail_ident):          res, req = self.client.delete("/mail/%s" % mail_ident)          return req | 
