• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python browse_page.BrowsePage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


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


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


示例4: test_expandable

 def test_expandable(self):
     """Expandable label value correctly displays on a Browse Page"""
     browse_page = BrowsePage(
         title='Browse Page',
         slug='browse',
     )
     browse_page.content = StreamValue(
         browse_page.content.stream_block,
         [atomic.expandable],
         True,
     )
     publish_page(child=browse_page)
     response = django_client.get('/browse/')
     self.assertContains(response, 'this is an expandable')
开发者ID:chosak,项目名称:cfgov-refresh,代码行数:14,代码来源:test_molecules.py


示例5: test_html_block

 def test_html_block(self):
     """ HTML Block correctly renders HTML on a Browse Page"""
     browse_page = BrowsePage(
         title='Browse Page',
         slug='browse',
     )
     browse_page.content = StreamValue(
         browse_page.content.stream_block,
         [atomic.html_block],
         True
     )
     publish_page(child=browse_page)
     response = self.client.get('/browse/')
     self.assertContains(response, 'Age 30 to 44')
开发者ID:amymok,项目名称:cfgov-refresh,代码行数:14,代码来源:test_organisms.py


示例6: test_expandable_group

 def test_expandable_group(self):
     """Expandable group correctly displays on a Browse Page"""
     browse_page = BrowsePage(
         title='Browse Page',
         slug='browse',
     )
     browse_page.content = StreamValue(
         browse_page.content.stream_block,
         [atomic.expandable_group],
         True
     )
     publish_page(child=browse_page)
     response = django_client.get('/browse/')
     self.assertContains(response, 'Expandable Group')
     self.assertContains(response, 'Expandable group body')
开发者ID:amymok,项目名称:cfgov-refresh,代码行数:15,代码来源:test_organisms.py


示例7: test_resource_list_set_col_width

    def test_resource_list_set_col_width(self):
        """ Resource List Assets column width is fixed when set"""
        assets_width_page = BrowsePage(
            title='Assets Width Test Page',
            slug='assets-width',
        )
        assets_width_page.content = StreamValue(
            assets_width_page.content.stream_block,
            [atomic.snippet_list_actions_column_width_40],
            True
        )
        publish_page(child=assets_width_page)

        self.create_resource()

        response = self.client.get('/assets-width/')
        self.assertContains(response, 'u-w40pct"')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:17,代码来源:test_organisms.py


示例8: test_resource_list_show_thumbnails_true

    def test_resource_list_show_thumbnails_true(self):
        """ Resource List shows thumbnails when show_thumbnails is True"""
        thumbnails_page = BrowsePage(
            title='Thumbnails Page',
            slug='thumbnails',
        )
        thumbnails_page.content = StreamValue(
            thumbnails_page.content.stream_block,
            [atomic.snippet_list_show_thumbnails_true],
            True
        )
        publish_page(child=thumbnails_page)

        self.create_resource()

        response = self.client.get('/thumbnails/')
        self.assertContains(response, 'o-resource-list_list-thumbnail')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:17,代码来源:test_organisms.py


示例9: test_resource_list_show_thumbnails_false

    def test_resource_list_show_thumbnails_false(self):
        """ Resource List doesn't show thumbs when show_thumbnails is False"""
        no_thumbnails_page = BrowsePage(
            title='No Thumbnails Page',
            slug='no-thumbnails',
        )
        no_thumbnails_page.content = StreamValue(
            no_thumbnails_page.content.stream_block,
            [atomic.snippet_list_show_thumbnails_false],
            True
        )
        publish_page(child=no_thumbnails_page)

        self.create_resource()

        response = self.client.get('/no-thumbnails/')
        self.assertNotContains(response, 'o-resource-list_list-thumbnail')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:17,代码来源:test_organisms.py


示例10: test_featured_content

 def test_featured_content(self):
     """Featured content value correctly displays on a Browse Page"""
     bp = BrowsePage(
         title='Browse Page',
         slug='browse-page',
     )
     bp.header = StreamValue(bp.header.stream_block,
     [
         atomic.featured_content
     ], True)
     bp.content = StreamValue(bp.content.stream_block,
     [
         atomic.expandable,
         atomic.expandable_group
     ], True)
     publish_page(child=bp)
     response = django_client.get('/browse-page/')
     self.assertContains(response, 'this is a featured content body')
开发者ID:chosak,项目名称:cfgov-refresh,代码行数:18,代码来源:test_molecules.py


示例11: test_resource_list

    def test_resource_list(self):
        """ Resource List renders thumbnails when show_thumbnails is True"""
        browse_page = BrowsePage(
            title='Browse Page',
            slug='browse',
        )
        browse_page.content = StreamValue(
            browse_page.content.stream_block,
            [atomic.snippet_list_show_thumbnails_false],
            True
        )
        publish_page(child=browse_page)

        self.create_resource()

        response = self.client.get('/browse/')
        self.assertContains(response, 'Test Resource List')
        self.assertContains(response, 'Test Resource')
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:18,代码来源:test_organisms.py


示例12: test_data_snapshot_with_inquiry_and_tightness

        def test_data_snapshot_with_inquiry_and_tightness(self):
            """ Management command correctly updates data snapshot values
            for market that contains inquiry and tightness data"""
            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)

            # Call management command to update values
            filename = os.path.join(
                settings.PROJECT_ROOT,
                'v1/tests/fixtures/data_snapshot.json'
            )
            call_command(
                'update_data_snapshot_values',
                '--snapshot_file={}'.format(filename)
            )
            # July 2018 
            response = self.client.get('/browse/')
            self.assertContains(response, '2.5 million') # Auto loans originated
            self.assertContains(response, '$54.6 billion') # Dollar volume of new loans
            self.assertContains(response, '7.3% increase') # In year-over-year originations 
            self.assertContains(response, 'July 2018')
            self.assertContains(response, 'Loans originated')
            self.assertContains(response, 'Dollar value of new loans')
            self.assertContains(response, 'In year-over-year originations')
            # Inquiry and tightness values
            self.assertContains(response, '7.9% increase')
            self.assertContains(response, '2.8% increase')
            self.assertContains(response, 'In year-over-year inquiries')
            self.assertContains(
                response,
                'In year-over-year credit tightness'
            )
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:42,代码来源:test_update_data_snapshot_values.py


示例13: 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 STU 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_snapshot.json'
            )
            call_command(
                'update_data_snapshot_values',
                '--snapshot_file={}'.format(filename)
            )
            response = self.client.get('/browse/')

            # July 2018 data:
            self.assertContains(response, '917,007') # Student loans originated
            self.assertContains(response, '$16.6 billion') # Dollar volume of new loans
            self.assertContains(response, '48.0% increase') # In year-over-year originations
            self.assertContains(response, 'July 2018')
            self.assertContains(response, 'Loans originated')
            self.assertContains(response, 'Dollar value of new loans')
            self.assertContains(response, 'In year-over-year originations')
            # Should not contain inquiry and tightness values
            self.assertNotContains(response, 'In year-over-year inquiries')
            self.assertNotContains(
                response,
                'In year-over-year credit tightness'
            )
开发者ID:cfpb,项目名称:cfgov-refresh,代码行数:40,代码来源:test_update_data_snapshot_values.py


示例14: test_data_snapshot

    def test_data_snapshot(self):
        """ Data Snapshot 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],
            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, 'Auto loans originated')
        self.assertContains(response, 'Dollar value of new loans')
        self.assertContains(response, 'In year-over-year originations')
开发者ID:amymok,项目名称:cfgov-refresh,代码行数:23,代码来源:test_organisms.py


示例15: test_chart_block

    def test_chart_block(self):
        """ Chart Block 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.chart_block],
            True
        )
        publish_page(child=browse_page)

        response = self.client.get('/browse/')
        self.assertContains(response, 'Volume of credit cards originated')
        self.assertContains(response, 'foo/bar.csv')
        self.assertContains(response, 'Data not final')
        self.assertContains(
            response,
            'The most recent data available in each visualization is for April 2016'
        )
        self.assertContains(response, 'January 2018')
开发者ID:amymok,项目名称:cfgov-refresh,代码行数:24,代码来源:test_organisms.py


示例16: run

def run():
    print 'Running script \'scripts.initial_test_data\' ...'

    admin_user = User.objects.filter(username='admin')
    if not admin_user:
        admin_user = User(username='admin',
                          password=make_password(os.environ.get('WAGTAIL_ADMIN_PW')),
                          is_superuser=True, is_active=True, is_staff=True)
        admin_user.save()
    else:
        admin_user = admin_user[0]


    # # Creates a new site root `CFGov`
    site_root = HomePage.objects.filter(title='CFGOV')
    if not site_root:
        root = Page.objects.first()
        site_root = HomePage(title='CFGOV', slug='home', depth=2, owner=admin_user)
        site_root.live = True
        root.add_child(instance=site_root)
        latest = site_root.save_revision(user=admin_user, submitted_for_moderation=False)
        latest.save()
    else:
        site_root = site_root[0]

    # Setting new site root
    site = Site.objects.first()
    if site.root_page_id != site_root.id:
        site.port = 8000
        site.root_page_id = site_root.id
        site.save()
        content_site = Site(hostname='content.localhost', port=8000, root_page_id=site_root.id)
        content_site.save()

    def publish_page(child=None, root=site_root):
        try:
            root.add_child(instance=child)
        except NodeAlreadySaved:
            pass
        revision = child.save_revision(
            user=admin_user,
            submitted_for_moderation=False,
        )
        revision.publish()

    # Create snippets
    contact = Contact.objects.filter(heading='Test User')
    if not contact:
        contact = Contact(heading='Test User')
    else:
        contact = contact[0]
    contact.contact_info = StreamValue(contact.contact_info.stream_block,
        [
            atomic.contact_email,
            atomic.contact_phone,
            atomic.contact_address
        ], True)
    contact.save()

    # Create each Page Type
    lap = LandingPage.objects.filter(title='Landing Page')
    if not lap:
        lap = LandingPage(title='Landing Page', slug='landing-page', owner=admin_user)
    else:
        lap = lap[0]
    lap.content = StreamValue(lap.content.stream_block,
        [
            atomic.image_text_25_75_group,
            atomic.image_text_50_50_group,
            atomic.half_width_link_blob_group,
            atomic.well
        ], True)
    lap.sidefoot = StreamValue(lap.sidefoot.stream_block,
        [
            atomic.related_links,
            atomic.sidebar_contact(contact.id)
        ], True)
    publish_page(lap)

    sp = SublandingPage.objects.filter(title='Sublanding Page')
    if not sp:
        sp = SublandingPage(title='Sublanding Page', slug='sublanding-page', owner=admin_user)
    else:
        sp = sp[0]
    sp.content = StreamValue(sp.content.stream_block,
        [
            atomic.main_contact_info(contact.id),
            atomic.reg_comment
        ], True)
    sp.sidefoot = StreamValue(sp.sidefoot.stream_block,
        [
            atomic.email_signup,
            atomic.rss_feed
        ], True)

    publish_page(sp)

    bp = BrowsePage.objects.filter(title='Browse Page')
    if not bp:
        bp = BrowsePage(title='Browse Page', slug='browse-page', owner=admin_user)
#.........这里部分代码省略.........
开发者ID:kurtrwall,项目名称:cfgov-refresh,代码行数:101,代码来源:initial_test_data.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.publish_page函数代码示例发布时间:2022-05-26
下一篇:
Python utils.spit_json函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap