Beispiel #1
0
 def update_user_rss(self, ids):
     users = User.query.filter(User.id.in_(ids)).all()
     app.logger.info(u"Admin Updating User RSS Feeds for Users: {0}".format(u", ".join(map(str, users))))
     userhandler = UserHandler()
     for user in users:
         userhandler.create_rss(user)
         db.session.add(user)
     db.session.commit()
Beispiel #2
0
def test_get_latest_entries(user1, session):
    entry1 = EntryFactory()
    entry2 = EntryFactory()
    entry3 = EntryFactory()
    entry4 = EntryFactory()
    author1 = AuthorFactory()
    author2 = AuthorFactory()
    author3 = AuthorFactory()
    author1.entries.append(entry1)
    author2.entries.append(entry2)
    author2.entries.append(entry3)
    author3.entries.append(entry4)

    sub1 = Subscription(user=user1, author=author1, active=True)
    sub2 = Subscription(user=user1, author=author2, active=True)
    sub3 = Subscription(user=user1, author=author3, active=False)

    session.commit()

    entries = Entry.query.all()
    assert len(entries) == 4

    authors = Author.query.all()
    assert len(authors) == 3

    subs = Subscription.query.all()
    assert len(subs) == 3

    userhandler = UserHandler()
    r = userhandler.get_latest_entries(user1.id, 10)
    assert len(r) == 3
    assert len(r) == len(set(r))

    user_authors = user1.authors
    for e in r:
        eSet = set(e.authors)
        assert eSet.intersection(user_authors)

    for i in range(len(r) - 1):
        assert r[i].published > r[i + 1].published