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


Python UserFactory.create_batch方法代码示例

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


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

示例1: test_get_bet_social

# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create_batch [as 别名]
 def test_get_bet_social(self):
     """
     Get bet social
     """
     event = EventFactory()
     users_yes = UserFactory.create_batch(10)
     users_no = UserFactory.create_batch(10)
     bets_yes = [BetFactory(user=u, event=event) for u in users_yes]
     bets_no = [BetFactory(user=u, event=event, outcome=Bet.NO) for u in users_no]
     self.maxDiff = None
     social = event.get_bet_social()
     self.assertEqual(10, social['yes_count'])
     self.assertEqual(bets_yes[:6], list(social['yes_bets']))
     self.assertEqual(10, social['no_count'])
     self.assertEqual(bets_no[:6], list(social['no_bets']))
开发者ID:KlubJagiellonski,项目名称:Politikon,代码行数:17,代码来源:tests.py

示例2: setUp

# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create_batch [as 别名]
    def setUp(self):

        HospitalFactory.create_batch(5)
        Hospital.objects.filter(id=1).update(is_kamc=True)

        SpecialtyFactory.create_batch(5)

        Department.objects.create(
            hospital=Hospital.objects.first(),
            specialty=Specialty.objects.first(),
            contact_name="",
            contact_position="",
            email="",
            phone="",
            extension="",
        )

        UserFactory.create_batch(10)

        super(ProtractorTests, self).setUp()
开发者ID:msarabi95,项目名称:easy-internship,代码行数:22,代码来源:tests.py

示例3: test_current_event_price

# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create_batch [as 别名]
 def test_current_event_price(self):
     """
     Current event price
     """
     event = EventFactory()
     users = UserFactory.create_batch(2)
     bet1 = BetFactory(event=event, user=users[0], outcome=Bet.YES)
     bet2 = BetFactory(event=event, user=users[1], outcome=Bet.NO)
     event.current_buy_for_price = 55
     event.current_buy_against_price = 45
     self.assertEqual(55, bet1.current_event_price())
     self.assertEqual(45, bet2.current_event_price())
开发者ID:KlubJagiellonski,项目名称:Politikon,代码行数:14,代码来源:tests.py

示例4: test_finish_yes

# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create_batch [as 别名]
    def test_finish_yes(self):
        """
        Finish event with outcome yes
        """
        users = UserFactory.create_batch(3)
        for u in users:
            u.portfolio_value = 1000
            u.total_cash = 2000
        event = EventFactory()
        bets = [BetFactory(event=event, user=user, has=3) for user in users[:2]]
        bets[1].outcome = Bet.NO
        bets[1].save()
        event.finish_yes()

        self.assertIsNotNone(event.end_date)
        self.assertEqual(Event.FINISHED_YES, event.outcome)

        event2 = EventFactory(outcome=Event.FINISHED_NO)
        with self.assertRaises(EventNotInProgress):
            event2.finish_yes()
开发者ID:KlubJagiellonski,项目名称:Politikon,代码行数:22,代码来源:tests.py

示例5: test_get_user_event_and_bet_for_update

# 需要导入模块: from accounts.factories import UserFactory [as 别名]
# 或者: from accounts.factories.UserFactory import create_batch [as 别名]
    def test_get_user_event_and_bet_for_update(self):
        """
        Get users event and bet for update
        """
        users = UserFactory.create_batch(2)
        events = EventFactory.create_batch(3)
        with self.assertRaises(NonexistantEvent):
            Bet.objects.get_user_event_and_bet_for_update(users[0], -1, Bet.YES)
        events[1].finish_yes()
        with self.assertRaises(EventNotInProgress):
            Bet.objects.get_user_event_and_bet_for_update(users[0], 2, Bet.YES)
        with self.assertRaises(UnknownOutcome):
            Bet.objects.get_user_event_and_bet_for_update(users[0], 1, 'OOOPS')
        new_bet = Bet.objects.get_user_event_and_bet_for_update(users[0], 1, Bet.YES)
        self.assertEqual(users[0], new_bet[0])
        self.assertEqual(events[0], new_bet[1])

        bet = BetFactory(user=users[1], event=events[2])
        self.assertEqual(
            (users[1], events[2], bet),
            Bet.objects.get_user_event_and_bet_for_update(users[1], 3, Bet.YES)
        )
开发者ID:KlubJagiellonski,项目名称:Politikon,代码行数:24,代码来源:tests.py


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