本文整理汇总了Python中v1.tests.wagtail_pages.helpers.save_new_page函数的典型用法代码示例。如果您正苦于以下问题:Python save_new_page函数的具体用法?Python save_new_page怎么用?Python save_new_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_new_page函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_answer_context_with_journey_referrer_and_default_category
def test_answer_context_with_journey_referrer_and_default_category(self):
""" If the referrer is a Buying a House journey page and 'mortgages'
category does not appear on answer page, breadcrumbs should lead
back to BAH & referrer pages, and category should default to first
category on answer."""
bah_page = BrowsePage(title='Buying a House', slug='owning-a-home')
helpers.publish_page(child=bah_page)
journey_path = JOURNEY_PATHS[0]
journey_page = BrowsePage(
title='Journey page',
slug=journey_path.strip('/').split('/')[-1]
)
helpers.save_new_page(journey_page, bah_page)
answer = self.answer1234
page = answer.english_page
page.category.add(self.category)
mock_site = mock.Mock()
mock_site.root_page = HomePage.objects.get(slug='cfgov')
request = HttpRequest()
request.META['HTTP_REFERER'] = \
'https://www.consumerfinance.gov' + journey_path
request.site = mock_site
context = page.get_context(request)
breadcrumbs = context['breadcrumb_items']
self.assertEqual(len(breadcrumbs), 2)
self.assertEqual(breadcrumbs[0]['title'], 'Buying a House')
self.assertEqual(breadcrumbs[1]['title'], 'Journey page')
self.assertEqual(context['category'], self.category)
示例2: test_answer_context_with_process_segment_in_journey_referrer
def test_answer_context_with_process_segment_in_journey_referrer(self):
"""If the referrer is a nested Buying a House journey page,
breadcrumbs should reflect the BAH page hierarchy."""
bah_page = BrowsePage(title='Buying a House', slug='owning-a-home')
helpers.publish_page(child=bah_page)
journey_page = BrowsePage(
title='Compare page',
slug='compare'
)
helpers.save_new_page(journey_page, bah_page)
page = self.page1
mock_site = mock.Mock()
mock_site.root_page = HomePage.objects.get(slug='cfgov')
request = HttpRequest()
request.META['HTTP_REFERER'] = \
'https://www.consumerfinance.gov/owning-a-home/process/compare/'
request.site = mock_site
context = page.get_context(request)
breadcrumbs = context['breadcrumb_items']
self.assertEqual(len(breadcrumbs), 2)
self.assertEqual(breadcrumbs[0]['title'], 'Buying a House')
self.assertEqual(breadcrumbs[1]['title'], 'Compare page')
示例3: setUp
def setUp(self):
self.request = mock.MagicMock()
self.request.site.hostname = 'localhost:8000'
self.limit = 10
self.sublanding_page = SublandingPage(title='title')
helpers.publish_page(child=self.sublanding_page)
self.post1 = BrowseFilterablePage(title='post 1')
self.post2 = BrowseFilterablePage(title='post 2')
# the content of this post has both a full_width_text
# and a filter_controls
self.post1.content = StreamValue(self.post1.content.stream_block,
[atomic.full_width_text, atomic.filter_controls],
True)
# this one only has a filter_controls
self.post2.content = StreamValue(self.post1.content.stream_block,
[atomic.filter_controls], True)
helpers.save_new_page(self.post1, self.sublanding_page)
helpers.save_new_page(self.post2, self.sublanding_page)
# manually set the publication date of the posts to ensure consistent
# order of retrieval in test situations, otherwise the `date_published`
# can vary due to commit order
self.child1_of_post1 = AbstractFilterPage(title='child 1 of post 1',
date_published=dt.date(2016, 9, 1))
self.child2_of_post1 = AbstractFilterPage(title='child 2 of post 1',
date_published=dt.date(2016, 9, 2))
self.child1_of_post2 = AbstractFilterPage(title='child 1 of post 2',
date_published=dt.date(2016, 9, 3))
helpers.save_new_page(self.child1_of_post1, self.post1)
helpers.save_new_page(self.child2_of_post1, self.post1)
helpers.save_new_page(self.child1_of_post2, self.post2)
示例4: test_related_posts_events_archive
def test_related_posts_events_archive(self):
"""
Tests whether related posts from archived events are retrieved.
Events have no specific categories associated with them so it
doesn't matter what that value is set to. Here, we save an
archived event child, and thus we expect that we should retrieve
both the original event child and the archive event child.
We also expect that no other categories (newsroom, blog) have
any posts in them.
"""
helpers.save_new_page(self.events_child2, self.archive_events_parent)
self.block.value['relate_posts'] = False
self.block.value['relate_newsroom'] = False
self.block.value['relate_events'] = True
self.block.value['specific_categories'] = ['anything', 'can', 'be', 'here']
related_posts = self.page_with_authors.related_posts(self.block, self.hostname)
self.assertIn('Events', related_posts)
self.assertEqual(len(related_posts['Events']), 2)
self.assertNotIn('Blog', related_posts)
self.assertNotIn('Newsroom', related_posts)
self.assertEqual(related_posts['Events'][0], self.events_child1)
self.assertEqual(related_posts['Events'][1], self.events_child2)
示例5: test_answer_context_with_nested_journey_referrer
def test_answer_context_with_nested_journey_referrer(self):
"""If the referrer is a nested Buying a House journey page,
breadcrumbs should reflect the BAH page hierarchy."""
bah_page = BrowsePage(title='Buying a House', slug='owning-a-home')
helpers.publish_page(child=bah_page)
journey_path = JOURNEY_PATHS[0]
journey_page = BrowsePage(
title='Journey page',
slug=journey_path.strip('/').split('/')[-1]
)
helpers.save_new_page(journey_page, bah_page)
journey_child_page = BrowsePage(
title='Journey child page',
slug='child'
)
helpers.save_new_page(journey_child_page, journey_page)
page = self.page1
mock_site = mock.Mock()
mock_site.root_page = HomePage.objects.get(slug='cfgov')
request = HttpRequest()
request.META['HTTP_REFERER'] = \
'https://www.consumerfinance.gov' + journey_path + '/child'
request.site = mock_site
context = page.get_context(request)
breadcrumbs = context['breadcrumb_items']
self.assertEqual(len(breadcrumbs), 3)
self.assertEqual(breadcrumbs[0]['title'], 'Buying a House')
self.assertEqual(breadcrumbs[1]['title'], 'Journey page')
self.assertEqual(breadcrumbs[2]['title'], 'Journey child page')
示例6: test_get_page_from_content
def test_get_page_from_content(self):
new_page = Page(title='test', slug='foo')
save_new_page(new_page, root=self.root)
self.assertEqual(
get_url_parts_for_site(new_page, self.content),
(self.content.id, self.content.root_url, '/foo/')
)
示例7: setUp
def setUp(self):
self.page = EventPage(
title='Super fun event', venue_city='Boston', venue_state='MA'
)
save_new_page(self.page)
self.migration = import_module(
'v1.migrations.0155_add_venue_coords_to_existing_events'
)
示例8: test_render_both_child_and_parent_page_provide_feed
def test_render_both_child_and_parent_page_provide_feed(self):
parent_page = SublandingFilterablePage(title='test', slug='test')
save_new_page(parent_page)
child_page = SublandingFilterablePage(title='test', slug='test')
save_new_page(child_page, root=parent_page)
html = self.render(context={'page': child_page})
self.assertHTMLContainsLinkToPageFeed(html, child_page)
示例9: make_page_with_category
def make_page_with_category(self, category_name):
page = AbstractFilterPage(title='test', slug='test')
save_new_page(page)
category = CFGOVPageCategory.objects.create(
name=category_name,
page=page
)
page.categories.add(category)
示例10: test_page_includes_rss_feed_of_parent
def test_page_includes_rss_feed_of_parent(self):
parent_page = SublandingFilterablePage(title='test', slug='test')
save_new_page(parent_page)
child_page = BlogPage(title='test', slug='test')
save_new_page(child_page, root=parent_page)
response = self.client.get('/test/test/')
self.assertContains(response, 'href="/test/feed/')
示例11: test_draft_page
def test_draft_page(self):
"""Draft page should not load in www"""
draft = LandingPage(
title='Draft Page',
slug='draft',
live=False,
)
save_new_page(child=draft)
www_response = django_client.get('/draft/')
self.assertEqual(www_response.status_code, 404)
示例12: setUp
def setUp(self):
from v1.tests.wagtail_pages.helpers import save_new_page
page_stub_30 = MortgagePerformancePage(
slug='mortgages-30-89-days-delinquent',
title='Mortgage Charts')
self.chart_page_30 = save_new_page(page_stub_30).as_page_object()
page_stub_90 = MortgagePerformancePage(
slug='mortgages-90-days-delinquent',
title='Mortgage Maps')
self.map_page_90 = save_new_page(page_stub_90).as_page_object()
示例13: setUp
def setUp(self):
self.root = Page.objects.get(slug='cfgov')
self.page = StreamPage(title="Test Page", slug="testpage")
save_new_page(self.page, self.root)
set_stream_data(self.page, 'body', [
{'type': 'text', 'value': 'some text'}
])
self.revision = self.page.save_revision()
self.page.save()
示例14: test_has_children_is_false_for_browse_page_with_only_non_browse_children
def test_has_children_is_false_for_browse_page_with_only_non_browse_children(self):
browse_page3 = BrowsePage(title='Browse page 3')
helpers.publish_page(child=browse_page3)
child_of_browse_page3 = CFGOVPage(title='Non-browse child of browse page')
helpers.save_new_page(child_of_browse_page3, browse_page3)
nav, has_children = util.get_secondary_nav_items(
self.request, browse_page3
)
self.assertEqual(has_children, False)
示例15: make_page_with_grades
def make_page_with_grades(self, *grades):
page = self.prepare_job_listing_page()
save_new_page(page)
for grade in grades:
panel = GradePanel.objects.create(
grade=mommy.make(Grade, grade=str(grade)),
job_listing=page
)
page.grades.add(panel)
return page