def test_post_and_update_feed(auto_login_user, broker, worker): client, user = auto_login_user() url = reverse('all-feeds-list') data = { "link": "https://feeds.feedburner.com/tweakers/mixed", "nickname": "test" } response = client.post(url, data, format='json') feed_id = response.data['id'] assert Entry.objects.count() == 0 response = client.get(url) assert response.data['count'] == 1 name = 'test2' data = {"nickname": name} content_type = 'application/json' response = client.patch(f'/api/v1/feed/{feed_id}/?force_update=true', data, content_type=content_type) assert response.status_code == status.HTTP_200_OK assert response.data['nickname'] == name broker.join("default") worker.join() assert Entry.objects.count() > 0
def test_register_and_update_feed_with_redirect(broker, worker): user = User.objects.create_user('john', '*****@*****.**', 'johnpassword') assert User.objects.count() == 1 feed = Feed.objects.create(link="http://www.nu.nl/rss/Algemeen", owner=user, nickname="test") feed.force_update() broker.join("default") worker.join() assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_register_and_update_feed_2(broker, worker): user = User.objects.create_user('john', '*****@*****.**', 'johnpassword') assert User.objects.count() == 1 feed = Feed.objects.create( link="https://feeds.feedburner.com/tweakers/mixed", owner=user, nickname="test") feed.force_update() broker.join("default") worker.join() assert Feed.objects.count() == 1 assert Entry.objects.count() > 0
def test_register_and_update_feed_twice(broker, worker): user = User.objects.create_user('john', '*****@*****.**', 'johnpassword') assert User.objects.count() == 1 feed = Feed.objects.create( link="https://feeds.feedburner.com/tweakers/mixed", owner=user, nickname="test") feed.force_update() feed.force_update() broker.join("default") worker.join() assert Feed.objects.count() == 1 # this is not very good cuz the feed might have more than 40 at some point # need a better way to check for double entries assert Entry.objects.count() < 50
def test_async_fetch_with_failed_notification_and_retry_with_success( broker, worker): print() user = User.objects.create_user('john', '*****@*****.**', 'johnpassword') assert User.objects.count() == 1 feed = Feed.objects.create(link="https://www.nu.nl/rss/AAAAAlgemeen", owner=user, nickname="test") feed.force_update() broker.join("default") worker.join() # only one notification per attempts of the same call assert Notification.objects.count( ) == 1, f'notification count error {Notification.objects.count()}' notification = Notification.objects.get() assert notification.title == "FeedError" assert Feed.objects.count() == 1 assert Entry.objects.count() == 0 # retry feed.link = "https://www.nu.nl/rss/Algemeen" feed.save() feed.force_update() broker.join("default") worker.join() count = Notification.objects.count() assert count == 2, f'notification count {count}' notification = Notification.objects.all() assert notification[0].title == "FeedUpdated"
def test_register_and_update_invalid_feed(broker, worker): user = User.objects.create_user('john', '*****@*****.**', 'johnpassword') assert User.objects.count() == 1 feed = Feed.objects.create( link="https://feeds.feedburner.com/WootWoot/mixed", owner=user, nickname="test") feed.force_update() broker.join("default") worker.join() time.sleep(2) print("updating again") feed.force_update() broker.join("default") worker.join() assert Feed.objects.count() == 1 assert Entry.objects.count() == 0