return the proper atom and rss content types for the feeds
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
parent
575e2ad387
commit
30d6f99c9b
|
@ -14,7 +14,7 @@ import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from feedgen.feed import FeedGenerator
|
from feedgen.feed import FeedGenerator
|
||||||
from flask import Blueprint, abort
|
from flask import Blueprint, Response, abort
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
|
|
||||||
from incorporealcms.lib import instance_resource_path_to_request_path, parse_md
|
from incorporealcms.lib import instance_resource_path_to_request_path, parse_md
|
||||||
|
@ -61,9 +61,9 @@ def serve_feed(feed_type):
|
||||||
fe.content(content, type='html')
|
fe.content(content, type='html')
|
||||||
|
|
||||||
if feed_type == 'atom':
|
if feed_type == 'atom':
|
||||||
return fg.atom_str(pretty=True)
|
return Response(fg.atom_str(pretty=True), mimetype='application/atom+xml')
|
||||||
else:
|
else:
|
||||||
return fg.rss_str(pretty=True)
|
return Response(fg.rss_str(pretty=True), mimetype='application/rss+xml')
|
||||||
|
|
||||||
|
|
||||||
def _generate_feed_id(feed_entry_path):
|
def _generate_feed_id(feed_entry_path):
|
||||||
|
|
|
@ -16,6 +16,7 @@ def test_atom_type_is_200(client):
|
||||||
"""Test that requesting an ATOM feed is found."""
|
"""Test that requesting an ATOM feed is found."""
|
||||||
response = client.get('/feed/atom')
|
response = client.get('/feed/atom')
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
assert 'application/atom+xml' in response.content_type
|
||||||
print(response.text)
|
print(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ def test_rss_type_is_200(client):
|
||||||
"""Test that requesting an RSS feed is found."""
|
"""Test that requesting an RSS feed is found."""
|
||||||
response = client.get('/feed/rss')
|
response = client.get('/feed/rss')
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
assert 'application/rss+xml' in response.content_type
|
||||||
print(response.text)
|
print(response.text)
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,13 +32,13 @@ def test_feed_generator_atom(app):
|
||||||
"""Test the root feed generator."""
|
"""Test the root feed generator."""
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
content = serve_feed('atom')
|
content = serve_feed('atom')
|
||||||
assert b'<id>https://example.com/</id>' in content
|
assert b'<id>https://example.com/</id>' in content.data
|
||||||
assert b'<email>admin@example.com</email>' in content
|
assert b'<email>admin@example.com</email>' in content.data
|
||||||
assert b'<name>Test Name</name>' in content
|
assert b'<name>Test Name</name>' in content.data
|
||||||
|
|
||||||
|
|
||||||
def test_feed_generator_rss(app):
|
def test_feed_generator_rss(app):
|
||||||
"""Test the root feed generator."""
|
"""Test the root feed generator."""
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
content = serve_feed('rss')
|
content = serve_feed('rss')
|
||||||
assert b'<author>admin@example.com (Test Name)</author>' in content
|
assert b'<author>admin@example.com (Test Name)</author>' in content.data
|
||||||
|
|
Loading…
Reference in New Issue