Add tests
This commit is contained in:
parent
91df9a8b43
commit
b0bb317be5
2 changed files with 27 additions and 1 deletions
|
@ -81,6 +81,7 @@ class FBInstantFeed(Rss201rev2Feed):
|
||||||
handler._write(force_text(item['content']))
|
handler._write(force_text(item['content']))
|
||||||
handler._write(']]>')
|
handler._write(']]>')
|
||||||
handler.endElement('content:encoded')
|
handler.endElement('content:encoded')
|
||||||
|
handler.addQuickElement('guid', item['guid'])
|
||||||
|
|
||||||
|
|
||||||
class FBInstantArticles(LatestEntriesFeed):
|
class FBInstantArticles(LatestEntriesFeed):
|
||||||
|
@ -101,4 +102,5 @@ class FBInstantArticles(LatestEntriesFeed):
|
||||||
return {
|
return {
|
||||||
'content': content,
|
'content': content,
|
||||||
'slug': item.safe_translation_getter('slug'),
|
'slug': item.safe_translation_getter('slug'),
|
||||||
|
'guid': item.guid,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import absolute_import, print_function, unicode_literals
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
from django.utils.encoding import force_text
|
||||||
|
|
||||||
from aldryn_apphooks_config.utils import get_app_instance
|
from aldryn_apphooks_config.utils import get_app_instance
|
||||||
from cms.toolbar.items import ModalItem
|
from cms.toolbar.items import ModalItem
|
||||||
|
@ -15,7 +16,7 @@ from parler.tests.utils import override_parler_settings
|
||||||
from parler.utils.conf import add_default_language_settings
|
from parler.utils.conf import add_default_language_settings
|
||||||
from parler.utils.context import smart_override, switch_language
|
from parler.utils.context import smart_override, switch_language
|
||||||
|
|
||||||
from djangocms_blog.feeds import LatestEntriesFeed, TagFeed
|
from djangocms_blog.feeds import LatestEntriesFeed, TagFeed, FBInstantArticles
|
||||||
from djangocms_blog.models import BLOG_CURRENT_NAMESPACE
|
from djangocms_blog.models import BLOG_CURRENT_NAMESPACE
|
||||||
from djangocms_blog.settings import get_setting
|
from djangocms_blog.settings import get_setting
|
||||||
from djangocms_blog.sitemaps import BlogSitemap
|
from djangocms_blog.sitemaps import BlogSitemap
|
||||||
|
@ -350,6 +351,29 @@ class ViewTest(BaseTest):
|
||||||
feed.config = self.app_config_1
|
feed.config = self.app_config_1
|
||||||
self.assertEqual(list(feed.items('tag-2')), [posts[0]])
|
self.assertEqual(list(feed.items('tag-2')), [posts[0]])
|
||||||
|
|
||||||
|
def test_instant_articles(self):
|
||||||
|
posts = self.get_posts()
|
||||||
|
pages = self.get_pages()
|
||||||
|
|
||||||
|
with smart_override('en'):
|
||||||
|
with switch_language(posts[0], 'en'):
|
||||||
|
request = self.get_page_request(
|
||||||
|
pages[1], self.user, path=posts[0].get_absolute_url()
|
||||||
|
)
|
||||||
|
|
||||||
|
feed = FBInstantArticles()
|
||||||
|
feed.namespace, feed.config = get_app_instance(request)
|
||||||
|
self.assertEqual(list(feed.items()), [posts[0]])
|
||||||
|
xml = feed(request)
|
||||||
|
self.assertContains(xml, '<guid>{0}</guid>'.format(posts[0].guid))
|
||||||
|
self.assertContains(xml, 'content:encoded')
|
||||||
|
self.assertContains(xml, 'class="op-published" datetime="{0}"'.format(
|
||||||
|
posts[0].date_published.isoformat()
|
||||||
|
))
|
||||||
|
self.assertContains(xml, '<link rel="canonical" href="{0}"/>'.format(
|
||||||
|
posts[0].get_full_url()
|
||||||
|
))
|
||||||
|
|
||||||
def test_sitemap(self):
|
def test_sitemap(self):
|
||||||
posts = self.get_posts()
|
posts = self.get_posts()
|
||||||
self.get_pages()
|
self.get_pages()
|
||||||
|
|
Loading…
Reference in a new issue