From 804d6fc6b9268577dbfd85f169f1a3f58e5cd6bc Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Fri, 24 Apr 2015 19:05:14 +0200 Subject: adding base unittests --- tests/controllers/__init__.py | 5 +++++ tests/controllers/article.py | 12 ++++++++++++ tests/controllers/feed.py | 15 +++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/controllers/__init__.py create mode 100644 tests/controllers/article.py create mode 100644 tests/controllers/feed.py (limited to 'tests/controllers') diff --git a/tests/controllers/__init__.py b/tests/controllers/__init__.py new file mode 100644 index 00000000..26922c43 --- /dev/null +++ b/tests/controllers/__init__.py @@ -0,0 +1,5 @@ +from tests.controllers.feed import FeedControllerTest +from tests.controllers.article import ArticleControllerTest + + +__all__ = ['FeedControllerTest', 'ArticleControllerTest'] diff --git a/tests/controllers/article.py b/tests/controllers/article.py new file mode 100644 index 00000000..b6c5225c --- /dev/null +++ b/tests/controllers/article.py @@ -0,0 +1,12 @@ +from tests.base import BasePyaggTest +from pyaggr3g470r.controllers import ArticleController + + +class ArticleControllerTest(BasePyaggTest): + _contr_cls = ArticleController + + def test_controller(self): + article = ArticleController(2).read()[0].dump() + self.assertFalse(article['readed']) + article['readed'] = True # article get read when retreived through get + self._test_controller_rights(article, article['user_id']) diff --git a/tests/controllers/feed.py b/tests/controllers/feed.py new file mode 100644 index 00000000..d8d6378b --- /dev/null +++ b/tests/controllers/feed.py @@ -0,0 +1,15 @@ +from tests.base import BasePyaggTest +from pyaggr3g470r.controllers import FeedController +from pyaggr3g470r.controllers import ArticleController + + +class FeedControllerTest(BasePyaggTest): + _contr_cls = FeedController + + def test_controller(self): + feed = FeedController(2).read()[0].dump() + self.assertTrue(3, ArticleController().read(feed_id=feed['id']).count()) + self._test_controller_rights(feed, feed['user_id']) + # checking articles are deleted after the feed has been deleted + self.assertFalse(0, + ArticleController().read(feed_id=feed['id']).count()) -- cgit From b6603ce4607982590d7d55c0d583809192d84cad Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Fri, 15 May 2015 00:21:40 +0200 Subject: testing special controller methods --- tests/controllers/article.py | 11 +++++++++++ tests/controllers/feed.py | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'tests/controllers') diff --git a/tests/controllers/article.py b/tests/controllers/article.py index b6c5225c..9a635fa7 100644 --- a/tests/controllers/article.py +++ b/tests/controllers/article.py @@ -10,3 +10,14 @@ class ArticleControllerTest(BasePyaggTest): self.assertFalse(article['readed']) article['readed'] = True # article get read when retreived through get self._test_controller_rights(article, article['user_id']) + self.assertEquals(0, len(list(ArticleController().challenge( + [{'id': art.id} for art in ArticleController(3).read()])))) + self.assertEquals(9, len(list(ArticleController(2).challenge( + [{'id': art.id} for art in ArticleController(3).read()])))) + self.assertEquals(9, len(list(ArticleController(2).challenge( + [{'entry_id': art.id} for art in ArticleController(3).read()] + )))) + self.assertEquals({1: 2, 2: 3, 3: 3}, + ArticleController(2).get_unread()) + self.assertEquals({4: 3, 5: 3, 6: 3}, + ArticleController(3).get_unread()) diff --git a/tests/controllers/feed.py b/tests/controllers/feed.py index d8d6378b..924b8ddd 100644 --- a/tests/controllers/feed.py +++ b/tests/controllers/feed.py @@ -8,8 +8,18 @@ class FeedControllerTest(BasePyaggTest): def test_controller(self): feed = FeedController(2).read()[0].dump() - self.assertTrue(3, ArticleController().read(feed_id=feed['id']).count()) + self.assertTrue(3, + ArticleController().read(feed_id=feed['id']).count()) self._test_controller_rights(feed, feed['user_id']) # checking articles are deleted after the feed has been deleted self.assertFalse(0, ArticleController().read(feed_id=feed['id']).count()) + + self.assertEquals(3, len(FeedController(3).list_fetchable())) + self.assertEquals(0, len(FeedController(3).list_fetchable())) + self.assertEquals(2, len(FeedController().list_fetchable())) + self.assertEquals(0, len(FeedController().list_fetchable())) + self.assertEquals(3, + len(FeedController(3).list_fetchable(refresh_rate=0))) + self.assertEquals(5, + len(FeedController().list_fetchable(refresh_rate=0))) -- cgit