diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-10-08 15:00:01 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2014-10-08 15:00:01 +0200 |
commit | e25e1f59a83a5ec7a8d363e2bd18c128c6729c48 (patch) | |
tree | 1e085b99014463d1449027edb748402078432e56 /service/test | |
parent | 9fd74021afb0a6d4551b21615f7094b1b0705f63 (diff) |
Filter tags by query (issue #52).
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/user_agent_test.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/service/test/user_agent_test.py b/service/test/user_agent_test.py index fea8393a..2f1ed01d 100644 --- a/service/test/user_agent_test.py +++ b/service/test/user_agent_test.py @@ -18,6 +18,8 @@ import unittest import pixelated.user_agent from pixelated.adapter.pixelated_mail import PixelatedMail from pixelated.adapter.pixelated_mail import InputMail +from pixelated.adapter.tag import Tag +from pixelated.adapter.tag_service import TagService from mockito import * import crochet import pixelated.reactor_manager as reactor_manager @@ -97,3 +99,21 @@ class UserAgentTest(unittest.TestCase): verify(pixelated.user_agent.app.config).from_pyfile('/tmp/some/config/file') finally: pixelated.user_agent.app.config = orig_config + + def test_that_tags_returns_all_tags(self): + when(self.mail_service).all_tags().thenReturn(TagService.SPECIAL_TAGS) + + response = self.app.get('/tags') + + self.assertEqual(200, response.status_code) + expected = json.dumps([tag.as_dict() for tag in TagService.SPECIAL_TAGS]) + self.assertEqual(expected, response.data) + + def test_that_tags_are_filtered_by_query(self): + when(self.mail_service).all_tags().thenReturn(TagService.SPECIAL_TAGS) + + response = self.app.get('/tags?q=dr') + + self.assertEqual(200, response.status_code) + expected = json.dumps([Tag('drafts', True).as_dict()]) + self.assertEqual(expected, response.data) |