本文整理匯總了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)
)