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


Python UserFactory.create_batch方法代码示例

本文整理汇总了Python中affiliates.users.tests.UserFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.create_batch方法的具体用法?Python UserFactory.create_batch怎么用?Python UserFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在affiliates.users.tests.UserFactory的用法示例。


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

示例1: test_not_authenticated

# 需要导入模块: from affiliates.users.tests import UserFactory [as 别名]
# 或者: from affiliates.users.tests.UserFactory import create_batch [as 别名]
    def test_not_authenticated(self):
        """
        If the current user isn't authenticated, render the home
        page with the correct stats.
        """
        request = self.factory.get('/')
        request.user = Mock()
        request.user.is_authenticated.return_value = False

        # User count = 27 + 8 autogenerated via related factory
        # Click count = 64
        # Link count = 3 + 5 autogenerated via related factory
        UserFactory.create_batch(27)
        for clicks in (4, 6, 9, 10):
            DataPointFactory.create(link_clicks=clicks, date=date(2014, 4, 26))
        for clicks in (25, 5, 5):
            LinkFactory.create(aggregate_link_clicks=clicks)

        # Create a link with multiple datapoints to test for a faulty
        # join that would screw up the totals.
        link = LinkFactory.create()
        DataPointFactory.create(link_clicks=7, link=link, date=date(2014, 4, 26))
        DataPointFactory.create(link_clicks=7, link=link, date=date(2014, 4, 27))

        with patch('affiliates.base.views.render') as render:
            eq_(views.home(request), render.return_value)
            render.assert_called_with(request, 'base/home.html', {
                'affiliate_count': 35,
                'link_count': 8,
                'click_count': 78
            })
开发者ID:Balachan,项目名称:affiliates,代码行数:33,代码来源:test_views.py

示例2: test_not_authenticated

# 需要导入模块: from affiliates.users.tests import UserFactory [as 别名]
# 或者: from affiliates.users.tests.UserFactory import create_batch [as 别名]
    def test_not_authenticated(self):
        """
        If the current user isn't authenticated, render the home
        page with the correct stats.
        """
        request = self.factory.get('/')
        request.user = Mock()
        request.user.is_authenticated.return_value = False

        # User count = 27 + 3 autogenerated via related factory
        # Link count = 3 autogenerated via related factory
        UserFactory.create_batch(27)
        LinkFactory.create_batch(3)


        with patch('affiliates.base.views.render') as render:
            with patch.object(Link.objects, 'total_link_clicks', return_value=64):
                eq_(views.home(request), render.return_value)
                render.assert_called_with(request, 'base/home.html', {
                    'affiliate_count': 30,
                    'link_count': 3,
                    'click_count': 64
                })
开发者ID:Acidburn0zzz,项目名称:affiliates,代码行数:25,代码来源:test_views.py


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