本文整理汇总了Python中v1.tests.wagtail_pages.helpers.save_new_page函数的典型用法代码示例。如果您正苦于以下问题:Python save_new_page函数的具体用法?Python save_new_page怎么用?Python save_new_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_new_page函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:higs4281,项目名称:cfgov-refresh,代码行数:30,代码来源:test_pages.py
示例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')
开发者ID:higs4281,项目名称:cfgov-refresh,代码行数:25,代码来源:test_pages.py
示例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)
开发者ID:amymok,项目名称:cfgov-refresh,代码行数:34,代码来源:test_sublanding_page.py
示例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)
开发者ID:marcesher,项目名称:cfgov-refresh,代码行数:25,代码来源:test_related_posts.py
示例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')
开发者ID:higs4281,项目名称:cfgov-refresh,代码行数:31,代码来源:test_pages.py
示例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/')
)
开发者ID:Newman101,项目名称:cfgov-refresh,代码行数:8,代码来源:test_routing.py
示例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'
)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:8,代码来源:test_0155_add_venue_coords_to_existing_events.py
示例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)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:9,代码来源:test_molecules.py
示例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)
开发者ID:Newman101,项目名称:cfgov-refresh,代码行数:9,代码来源:test_browse_filterable_page.py
示例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/')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:9,代码来源:test_blog_page.py
示例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)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:10,代码来源:test_page_states.py
示例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()
开发者ID:OrlandoSoto,项目名称:cfgov-refresh,代码行数:10,代码来源:test_models.py
示例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()
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:10,代码来源:test_migrations.py
示例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)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:11,代码来源:test_util.py
示例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
开发者ID:OrlandoSoto,项目名称:cfgov-refresh,代码行数:12,代码来源:test_pages.py
示例16: test_has_children_is_true_for_browse_page_with_browse_filterable_child
def test_has_children_is_true_for_browse_page_with_browse_filterable_child(self):
browse_filterable_page = BrowsePage(title='Non-browse page')
helpers.publish_page(child=browse_filterable_page)
browse_filterable_page_child = BrowseFilterablePage(
title='Child of non-browse page'
)
helpers.save_new_page(
browse_filterable_page_child, browse_filterable_page
)
nav, has_children = util.get_secondary_nav_items(
self.request, browse_filterable_page
)
self.assertEqual(has_children, True)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:14,代码来源:test_util.py
示例17: test_page_renders_block_safely
def test_page_renders_block_safely(self):
"""
Test to make sure that a page with a jobs list block renders it
in a safe way, meaning as raw HTML vs. as a quoted string.
"""
page = SublandingPage(title='title', slug='slug')
save_new_page(page)
set_stream_data(page, 'sidebar_breakout', [job_listing_list])
self.assertPageIncludesHtml(page, (
'><aside class="m-jobs-list" data-qa-hook="openings-section">'
'.*'
'</aside><'
))
开发者ID:chosak,项目名称:cfgov-refresh,代码行数:14,代码来源:test_blocks.py
示例18: setUp
def setUp(self):
self.request = mock.MagicMock()
self.browse_page1 = BrowsePage(title='Browse page 1')
self.browse_page2 = BrowsePage(title='Browse page 2')
helpers.publish_page(child=self.browse_page1)
helpers.publish_page(child=self.browse_page2)
self.child_of_browse_page1 = BrowsePage(
title='Child of browse page 1'
)
self.child_of_browse_page2 = BrowsePage(
title='Child of browse page 2'
)
helpers.save_new_page(self.child_of_browse_page1, self.browse_page1)
helpers.save_new_page(self.child_of_browse_page2, self.browse_page2)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:14,代码来源:test_util.py
示例19: test_live_draft_page
def test_live_draft_page(self):
""" Live draft page should not display unpublished content"""
live_draft = LandingPage(
title='Page Before Updates',
slug='page',
live=False,
)
save_new_page(live_draft).publish()
live_draft.title = 'Draft Page Updates'
live_draft.save_revision()
www_response = django_client.get('/page/')
self.assertNotContains(www_response, 'Draft Page Updates')
self.assertContains(www_response, 'Page Before Updates')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:16,代码来源:test_page_states.py
示例20: test_page_renders_block_safely
def test_page_renders_block_safely(self):
"""
Test to make sure that a page with a jobs list block renders it
in a safe way, meaning as raw HTML vs. as a quoted string.
"""
page = SublandingPage(title='title', slug='slug')
save_new_page(page)
set_stream_data(page, 'sidebar_breakout', [job_listing_list])
request = RequestFactory().get('/')
request.user = Mock()
rendered_html = force_text(page.serve(request).render().content)
self.assertInHTML(
('<aside class="m-jobs-list" data-qa-hook="openings-section">'
'<h3 class="short-desc">There are no current openings at this '
'time.</h3></aside>'),
rendered_html
)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:18,代码来源:test_blocks.py
注:本文中的v1.tests.wagtail_pages.helpers.save_new_page函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论