当前位置: 首页>>代码示例>>Python>>正文


Python helpers.publish_page函数代码示例

本文整理汇总了Python中v1.tests.wagtail_pages.helpers.publish_page函数的典型用法代码示例。如果您正苦于以下问题:Python publish_page函数的具体用法?Python publish_page怎么用?Python publish_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了publish_page函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     division = JobCategory(
         job_category="category"
     )
     division.save()
     region = Region(
         abbreviation="TS",
         name="TriStateArea"
     )
     region.save()
     self.public_type = ApplicantType(
         applicant_type="public",
         description="description"
     )
     self.public_type.save()
     self.status_type = ApplicantType(
         applicant_type="status",
         description="description"
     )
     self.status_type.save()
     self.page = JobListingPage(
         title='title1',
         salary_min='1',
         salary_max='2',
         description='description',
         open_date=date(2099, 1, 1),
         close_date=date(2099, 1, 15),
         division=division,
         location=region,
         live=True)
     helpers.publish_page(child=self.page)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:31,代码来源:test_unpublish_closed_jobs.py

示例2: test_data_snapshot

        def test_data_snapshot(self):
            """ Management command correctly updates data snapshot values"""
            browse_page = BrowsePage(
                title='Browse Page',
                slug='browse',
            )

            # Adds a AUT market to a browse page
            browse_page.content = StreamValue(
                browse_page.content.stream_block,
                [atomic.data_snapshot],
                True
            )
            publish_page(child=browse_page)

            # Call management command to update values
            filename = os.path.join(
                settings.PROJECT_ROOT,
                'v1/tests/fixtures/data_snapshots.json'
            )
            call_command(
                'update_data_snapshot_values',
                '--snapshot_file={}'.format(filename)
            )
            response = self.client.get('/browse/')
            self.assertContains(response, '2.1 million')
            self.assertContains(response, '$46.4 billion')
            self.assertContains(response, '5.8% increase')
            self.assertContains(response, 'March 2017')
            self.assertContains(response, 'Auto loans originated')
            self.assertContains(response, 'Dollar value of new loans')
            self.assertContains(response, 'In year-over-year originations')
开发者ID:OrlandoSoto,项目名称:cfgov-refresh,代码行数:32,代码来源:test_update_data_snapshot_values.py

示例3: test_chart_block_inquiry_activity

        def test_chart_block_inquiry_activity(self):
            """ Management command correctly updates chart block dates for inquiry index charts"""
            browse_page = BrowsePage(
                title='Browse Page',
                slug='browse',
            )

            # Adds a Chart Block to a browse page
            browse_page.content = StreamValue(
                browse_page.content.stream_block,
                [atomic.chart_block_inquiry_activity],
                True
            )
            publish_page(child=browse_page)

            # Call management command to update values
            filename = os.path.join(
                settings.PROJECT_ROOT,
                'v1/tests/fixtures/data_snapshot.json'
            )
            call_command(
                'update_chart_block_dates',
                '--snapshot_file={}'.format(filename)
            )
            response = self.client.get('/browse/')

            # Tests last_updated_projected_data is correct
            self.assertContains(
                response,
                'The most recent data available in this visualization are for June 2018'
            )

            # Tests date_published is correct
            self.assertContains(response, 'October 2018')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:34,代码来源:test_update_chart_block_dates.py

示例4: test_no_duplicates

 def test_no_duplicates(self):
     """ Page should show up once in results,
     even if field the link is in belongs to a parent page
     """
     page = BlogPage(
         title='Test Blog Page',
         slug='test-blog-page',
         sidefoot=json.dumps([{
             'type': 'related_links',
             'value': {
                 'links': [
                     {
                         'url': 'https://www.foobar.com',
                         'text': ''
                     }
                 ]
             },
         }])
     )
     publish_page(page)
     response = self.client.post('/admin/external-links/', {
         'url': 'www.foobar.com'
     })
     self.assertContains(
         response,
         "There is 1 matching page and 0 matching snippets"
     )
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:27,代码来源:test_views.py

示例5: test_cache_gets_called_when_visiting_filterable_page

    def test_cache_gets_called_when_visiting_filterable_page(self):
        # Create a filterable page
        page = BrowseFilterablePage(
            title='test browse filterable page',
            slug='test-browse-filterable-page'
        )
        page.content = StreamValue(
            page.content.stream_block,
            [atomic.filter_controls],
            True
        )
        publish_page(page)

        # Add a child to that filterable page so that there are results
        # with a post preview
        child_page = BlogPage(
            title='test blog page',
            slug='test-blog-page'
        )
        page.add_child(instance=child_page)

        cache = caches['post_preview']
        with patch.object(cache, 'add') as add_to_cache:
            # Navigate to the filterable page so that `post-preview.html` loads
            self.client.get('/test-browse-filterable-page/')

            self.assertTrue(add_to_cache.called)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:27,代码来源:test_fragment_cache.py

示例6: 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

示例7: 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

示例8: test_ping_google_when_job_page_published

 def test_ping_google_when_job_page_published(self, flag_enabled_check):
     with patch('requests.get') as mock_request:
         helpers.publish_page(child=self.page)
         mock_request.assert_called_once_with(
             'https://www.google.com/ping',
             {'sitemap': 'https://www.consumerfinance.gov/sitemap.xml'}
         )
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:7,代码来源:test_signals.py

示例9: 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

示例10: test_data_snapshot_with_optional_fields

    def test_data_snapshot_with_optional_fields(self):
        """ Data Snapshot with inquiry and tightness information correctly renders
        fields on a Browse Page"""
        browse_page = BrowsePage(
            title='Browse Page',
            slug='browse',
        )

        # Adds a AUT market to a browse page
        browse_page.content = StreamValue(
            browse_page.content.stream_block,
            [atomic.data_snapshot_with_optional_fields],
            True
        )
        publish_page(child=browse_page)

        response = self.client.get('/browse/')
        self.assertContains(response, '5 million')
        self.assertContains(response, '$64 billion')
        self.assertContains(response, '5% increase')
        self.assertContains(response, 'January 2015')
        self.assertContains(response, 'Loans originated')
        self.assertContains(response, 'Dollar value of new loans')
        self.assertContains(response, 'In year-over-year originations')
        # Should  include inquiry or tightness information
        self.assertContains(response, '7.4% decrease')
        self.assertContains(response, 'In year-over-year inquiries')
        self.assertContains(response, '2.8% increase')
        self.assertContains(response, 'In year-over-year credit tightness')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:29,代码来源:test_organisms.py

示例11: add_reusable_text_snippet

def add_reusable_text_snippet(slug, cls):
    snippet_with_heading = ReusableText(
        title='Test reusable text snippet with sidefoot heading',
        sidefoot_heading='Test sidefoot heading',
        text='A reusable snippet with a sidefoot heading',
    )
    snippet_without_heading = ReusableText(
        title='Test reusable text snippet without a sidefoot heading',
        text='A reusable snippet without a sidefoot heading.',
    )
    snippet_with_heading.save()
    snippet_without_heading.save()
    full_width_text = {
        'type': 'full_width_text',
        'value': [
            {
                'type': 'reusable_text',
                'value': snippet_with_heading.id
            },
            {
                'type': 'reusable_text',
                'value': snippet_without_heading.id
            }
        ]
    }
    page = cls(
        title=slug,
        slug=slug,
    )
    page.content = StreamValue(
        page.content.stream_block,
        [full_width_text],
        True,
    )
    publish_page(page)
开发者ID:contolini,项目名称:cfgov-refresh,代码行数:35,代码来源:test_data.py

示例12: add_jobs_listing_page

def add_jobs_listing_page(slug, cls):
    job_category = JobCategory(
        job_category='CFPB Testing job category',
        blurb='CFPB Testing blurb'
    )
    job_category.save()

    job_region = JobLocation(
        abbreviation='TR',
        name='Testing Region'
    )
    job_region.save()

    jobs_listing_page = cls(
        close_date=datetime.now() + timedelta(days=30),
        description='Test Job Description',
        division=job_category,
        open_date=datetime.today(),
        salary_max=120000,
        salary_min=95000,
        slug=slug,
        title=slug,
        location=job_region
    )

    publish_page(jobs_listing_page)
开发者ID:contolini,项目名称:cfgov-refresh,代码行数:26,代码来源:test_data.py

示例13: 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

示例14: test_single_result_per_page

 def test_single_result_per_page(self):
     """ Page should show up once in results,
     even if the same link occurs multiple times in it.
     """
     page = BlogPage(
         title='Test Blog Page',
         slug='test-blog-page',
         content=json.dumps([{
             'type': 'well',
             'value': {
                 'content': '<a href=https://www.foobar.com>...</a>'
             },
         }]),
         header=json.dumps([{
             'type': 'text_introduction',
             'value': {
                 'intro': '<a href=https://www.foobar.com>...</a>'
             },
         }])
     )
     publish_page(page)
     response = self.client.post('/admin/external-links/', {
         'url': 'www.foobar.com'
     })
     self.assertContains(
         response,
         "There is 1 matching page and 0 matching snippets"
     )
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:28,代码来源:test_views.py

示例15: test_filter_by_title

 def test_filter_by_title(self):
     page1 = EventPage(title='Cool Event')
     page2 = EventPage(title='Awesome Event')
     publish_page(page1)
     publish_page(page2)
     form = self.setUpFilterableForm(data={'title': 'Cool'})
     page_set = form.get_page_set()
     self.assertEquals(len(page_set), 1)
     self.assertEquals(page_set[0].specific, page1)
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:9,代码来源:test_filterable_list_form.py


注:本文中的v1.tests.wagtail_pages.helpers.publish_page函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。