diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-12-17 13:05:26 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-12-17 13:05:26 +0100 |
commit | 0312e25586d381cc53935c2fd4912378cd292d6e (patch) | |
tree | b04ad1a26edd4c67701d0d704c8ce8c554b2ae42 /src/tests/fixtures.py | |
parent | Updated link to Heroku deploy button on the About page. (diff) | |
parent | handling failing feed link (diff) | |
download | newspipe-0312e25586d381cc53935c2fd4912378cd292d6e.tar.gz newspipe-0312e25586d381cc53935c2fd4912378cd292d6e.tar.bz2 newspipe-0312e25586d381cc53935c2fd4912378cd292d6e.zip |
Merge pull request #24 from jaesivsm/master
moving the root of source code from / to /src/
Diffstat (limited to 'src/tests/fixtures.py')
-rw-r--r-- | src/tests/fixtures.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/fixtures.py b/src/tests/fixtures.py new file mode 100644 index 00000000..99f46c37 --- /dev/null +++ b/src/tests/fixtures.py @@ -0,0 +1,31 @@ +from web.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) |