本文整理汇总了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']))
示例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()
示例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())
示例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()
示例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)
)