Ejemplo n.º 1
0
def test_fetch_feed_not_modified_last_modified(
    session, capture_signal_notification_received
):
    feed = Feed(topic="http://test.com/feed.rss")
    content_hash = "adfasdfasd"
    feed.content_hash = content_hash
    modified = datetime(2017, 6, 6, 12, 0, 0)

    responses.add(
        responses.GET,
        feed.topic,
        body=None,
        status=304,
        adding_headers={"last-modified": create_modified_header(modified)},
        content_type="application/rss+xml",
    )

    result = FeedFetcher.fetch_feed(feed)
    assert result is False
    assert feed.last_status_code == 304
    assert not feed.etag
    assert feed.last_modified == modified
    assert feed.content_hash == content_hash
    assert feed.next_scheduled_update > Feed.current_timestamp()

    assert len(capture_signal_notification_received) == 0

    stats = FeedStats.query.filter_by(feed_id=feed.id).first()
    assert stats
    assert stats.status_code == 304
    assert stats.new_entries == 0
    assert stats.updated_entries == 0
    assert stats.type == FetchType.PULL
    assert stats.latency > 0
    assert stats.parse_time == 0