diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 5 | ||||
-rw-r--r-- | service/pixelated/adapter/services/tag_service.py | 1 | ||||
-rw-r--r-- | service/test/integration/test_tags.py | 19 |
3 files changed, 22 insertions, 3 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 1e0a0414..40a7c6ff 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -35,7 +35,7 @@ class MailService: return self.querier.mails(mail_ids), total def update_tags(self, mail_id, new_tags): - new_tags = [x.lower() for x in map(lambda e: e.strip(), new_tags) if x != ''] + new_tags = self._filter_white_space_tags(new_tags) reserved_words = self.tag_service.extract_reserved(new_tags) if len(reserved_words): raise ValueError('None of the following words can be used as tags: ' + ' '.join(reserved_words)) @@ -45,6 +45,9 @@ class MailService: return mail + def _filter_white_space_tags(self, tags): + return filter(bool, map(lambda e: e.strip(), tags)) + def mail(self, mail_id): return self.querier.mail(mail_id) diff --git a/service/pixelated/adapter/services/tag_service.py b/service/pixelated/adapter/services/tag_service.py index 22cfb051..601392bb 100644 --- a/service/pixelated/adapter/services/tag_service.py +++ b/service/pixelated/adapter/services/tag_service.py @@ -23,4 +23,5 @@ class TagService: @classmethod def extract_reserved(cls, tags): + tags = map(lambda tag: tag.lower(), tags) return {tag.name for tag in cls.SPECIAL_TAGS if tag.name in tags} diff --git a/service/test/integration/test_tags.py b/service/test/integration/test_tags.py index 1de6d3fa..41aeeeeb 100644 --- a/service/test/integration/test_tags.py +++ b/service/test/integration/test_tags.py @@ -31,11 +31,26 @@ class TagsTest(SoledadTestBase): self.post_tags(mail.ident, self._tags_json(['IMPORTANT'])) mails = self.get_mails_by_tag('inbox') - self.assertEquals({'important'}, set(mails[0].tags)) + self.assertEquals({'IMPORTANT'}, set(mails[0].tags)) - mails = self.get_mails_by_tag('important') + mails = self.get_mails_by_tag('IMPORTANT') self.assertEquals('Mail with tags', mails[0].subject) + def test_tags_are_case_sensitive(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(['ImPoRtAnT'])) + + mails = self.get_mails_by_tag('important') + self.assertEquals(0, len(mails)) + + mails = self.get_mails_by_tag('IMPORTANT') + self.assertEquals(0, len(mails)) + + mails = self.get_mails_by_tag('ImPoRtAnT') + self.assertEquals({'ImPoRtAnT'}, set(mails[0].tags)) + 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) |