aboutsummaryrefslogtreecommitdiff
path: root/tests/fixtures.py
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-05-15 07:24:18 +0200
committerCédric Bonhomme <kimble.mandel+bitbucket@gmail.com>2015-05-15 07:24:18 +0200
commitdd059ad8a7d94ea6d03639e10e4d41c95dd1cebd (patch)
tree8aa3c0bf481a67717987af0710540668d3467ab0 /tests/fixtures.py
parentThe list of inactive feeds is now sorted. (diff)
parenttesting special controller methods (diff)
downloadnewspipe-dd059ad8a7d94ea6d03639e10e4d41c95dd1cebd.tar.gz
newspipe-dd059ad8a7d94ea6d03639e10e4d41c95dd1cebd.tar.bz2
newspipe-dd059ad8a7d94ea6d03639e10e4d41c95dd1cebd.zip
Merged in jaesivsm/pyaggr3g470r (pull request #13)
introducing unittests !
Diffstat (limited to 'tests/fixtures.py')
-rw-r--r--tests/fixtures.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/fixtures.py b/tests/fixtures.py
new file mode 100644
index 00000000..6aab645d
--- /dev/null
+++ b/tests/fixtures.py
@@ -0,0 +1,31 @@
+from pyaggr3g470r.models import db_create, db_empty, User, Article, Feed
+
+
+def populate_db(db):
+ role_admin, role_user = db_create(db)
+ user1, user2 = [User(nickname=name, email="%s@test.te" % name,
+ pwdhash=name, roles=[role_user], activation_key="")
+ for name in ["user1", "user2"]]
+ db.session.add(user1)
+ db.session.add(user2)
+ db.session.commit()
+
+ for user in (user1, user2):
+ for feed_name in ['feed1', 'feed2', 'feed3']:
+ feed = Feed(link=feed_name, user_id=user.id,
+ title="%r %r" % (user.nickname, feed_name))
+ db.session.add(feed)
+ db.session.commit()
+ for article in ['article1', 'article2', 'article3']:
+ 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=entry, content=article)
+ db.session.add(article)
+ db.session.commit()
+
+ db.session.commit()
+
+
+def reset_db(db):
+ db_empty(db)
bgstack15