aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-05-15 00:21:40 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-05-15 00:22:08 +0200
commitb6603ce4607982590d7d55c0d583809192d84cad (patch)
tree8aa3c0bf481a67717987af0710540668d3467ab0
parentadding base unittests (diff)
downloadnewspipe-b6603ce4607982590d7d55c0d583809192d84cad.tar.gz
newspipe-b6603ce4607982590d7d55c0d583809192d84cad.tar.bz2
newspipe-b6603ce4607982590d7d55c0d583809192d84cad.zip
testing special controller methods
-rw-r--r--pyaggr3g470r/models/article.py1
-rw-r--r--tests/controllers/article.py11
-rw-r--r--tests/controllers/feed.py12
-rw-r--r--tests/fixtures.py7
4 files changed, 26 insertions, 5 deletions
diff --git a/pyaggr3g470r/models/article.py b/pyaggr3g470r/models/article.py
index 3151071a..16f15b9e 100644
--- a/pyaggr3g470r/models/article.py
+++ b/pyaggr3g470r/models/article.py
@@ -74,6 +74,7 @@ class Article(db.Model):
def dump(self):
return {"id": self.id,
"user_id": self.user_id,
+ "entry_id": self.entry_id,
"title": self.title,
"link": self.link,
"content": self.content,
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)))
diff --git a/tests/fixtures.py b/tests/fixtures.py
index bc783847..6aab645d 100644
--- a/tests/fixtures.py
+++ b/tests/fixtures.py
@@ -17,11 +17,10 @@ def populate_db(db):
db.session.add(feed)
db.session.commit()
for article in ['article1', 'article2', 'article3']:
- article = Article(entry_id=article, link=article,
+ entry = "%s %s %s" % (user.nickname, feed.title, article)
+ article = Article(entry_id=entry, link=article,
feed_id=feed.id, user_id=user.id,
- title="%r %r %r" % (user.nickname,
- feed.title, article),
- content=article)
+ title=entry, content=article)
db.session.add(article)
db.session.commit()
bgstack15