本文整理汇总了Python中test_factory.Factory.account方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.account方法的具体用法?Python Factory.account怎么用?Python Factory.account使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test_factory.Factory
的用法示例。
在下文中一共展示了Factory.account方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_saving_a_blank_group_gives_it_a_filler_name
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
def test_saving_a_blank_group_gives_it_a_filler_name(self):
account = Factory.account()
ts = TagSet.raw_objects.create(account=account)
self.assertEqual(ts.name,BLANK_TAGSET_NAME)
ts.name = "foo"
ts.save()
self.assertEqual(ts.name,"foo")
ts.name = ""
ts.save()
self.assertEqual(ts.name,BLANK_TAGSET_NAME)
示例2: test_objects_by_account_limits_to_account
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
def test_objects_by_account_limits_to_account(self, model=Person, factory_method=Factory.person, **kwargs):
a1 = Factory.account("test1",delete_existing=True)
g1 = factory_method(account=a1, **kwargs)
a2 = Factory.account("test2",delete_existing=True)
g2 = factory_method(account=a2, **kwargs)
request = Dummy()
request.account = a1
self.assertNotEqual(a1,a2)
self.assertNotEqual(g1,g2)
self.assertEqual([g for g in model.objects_by_account(a1).all()], [g1])
self.assertEqual([g for g in model.objects_by_account(request).all()], [g1])
self.assertEqual([g for g in model.objects_by_account(a2).all()], [g2])
try:
self.assertEqual([g for g in model.raw_objects.all()],[g1, g2])
except:
self.assertEqual([g for g in model.raw_objects.all()],[g2, g1])
示例3: test_completed_shifts_by_year_returns_sanely
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
def test_completed_shifts_by_year_returns_sanely():
account = Factory.account()
person = Factory.person(account)
today = datetime.date.today()
s1 = CompletedShift.raw_objects.create(account=account, volunteer=person.volunteer, duration=5, date=today)
s2 = CompletedShift.raw_objects.create(account=account, volunteer=person.volunteer, duration=1, date=today)
target = [{'shifts': [s2, s1],
'total_hours': s1.duration+s2.duration,
'total_shifts': 2,
'year': today.year
}]
assert person.volunteer.completed_shifts_by_year == target
示例4: test_donations_by_year_returns_sanely
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
def test_donations_by_year_returns_sanely():
account = Factory.account()
person = Factory.person(account)
today = datetime.date.today()
d1 = Donation.raw_objects.create(account=account, donor=person.donor, amount=5, date=today)
d2 = Donation.raw_objects.create(account=account, donor=person.donor, amount=41, date=datetime.datetime.now()-datetime.timedelta(days=1))
d3 = Donation.raw_objects.create(account=account, donor=person.donor, amount=41, date=datetime.datetime.now()-datetime.timedelta(days=360))
target = [{'donations': [d1, d2],
'total_donations': d1.amount+d2.amount,
'total_number_of_donations':2,
'year': today.year
},{'donations': [d3],
'total_donations': d3.amount,
'total_number_of_donations':1,
'year': d3.date.year
}]
assert person.donor.donations_by_year == target
示例5: setUp
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
def setUp(self):
self.account = Factory.account()
populate_rule_components_for_an_account(self.account)
self.request = Dummy()
self.request.account = self.account
示例6: test_completed_shifts_by_year_for_non_volunteer_returns_properly
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
def test_completed_shifts_by_year_for_non_volunteer_returns_properly():
account = Factory.account()
person = Factory.person(account)
target = []
assert person.volunteer.completed_shifts_by_year == target