本文整理汇总了Python中test_factory.Factory.person方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.person方法的具体用法?Python Factory.person怎么用?Python Factory.person使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test_factory.Factory
的用法示例。
在下文中一共展示了Factory.person方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_that_requesting_an_invalid_person_404s
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def test_that_requesting_an_invalid_person_404s(self):
sel = self.selenium
cache.clear()
self.go_to_the_login_page()
self.log_in()
self.assert_login_succeeded()
# make sure to make a new person
for i in range(0,20):
Factory.person(account=self.a1)
self.create_john_smith_and_verify()
# get pk
url = sel.get_location()
person_url = url[url.find(":%s/" % settings.LIVE_SERVER_PORT)+5:]
a2 = self.create_demo_site("test2")
ua = Factory.useraccount(account=a2)
self.go_to_the_login_page(site="test2")
self.log_in(ua=ua)
self.open(person_url, site="test2")
assert sel.is_text_present("not found")
示例2: _generate_people
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def _generate_people(self, number=5):
from volunteers import VOLUNTEER_STATII
people = []
for i in range(0,number):
p = Factory.person(self.account)
v = p.volunteer
v.status = VOLUNTEER_STATII[1][0]
v.save()
people.append(p.pk)
people = Person.objects_by_account(self.account).filter(pk__in=people)
return people
示例3: test_age_and_next_age
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def test_age_and_next_age(self):
today = datetime.date.today()
today_20_years_ago = datetime.date(year=today.year-20, day=today.day, month=today.month)
yesterday_20_years_ago = today_20_years_ago - datetime.timedelta(days=1)
tomorrow_20_years_ago = today_20_years_ago + datetime.timedelta(days=1)
p1 = Factory.person(account=self.account, birthday=yesterday_20_years_ago)
p2 = Factory.person(account=self.account, birthday=today_20_years_ago)
p3 = Factory.person(account=self.account, birthday=tomorrow_20_years_ago)
p4 = Factory.person(account=self.account)
p4.birth_year = None
p4.birth_day = 4
p4.birth_month = 9
p4.save()
self.assertEqual(p1.age, 20)
self.assertEqual(p2.age, 20)
self.assertEqual(p3.age, 19)
self.assertEqual(p4.age, None)
self.assertEqual(p1.next_or_todays_birthday_age, 21)
self.assertEqual(p2.next_or_todays_birthday_age, 20)
self.assertEqual(p3.next_or_todays_birthday_age, 20)
self.assertEqual(p4.next_or_todays_birthday_age, None)
示例4: test_completed_shifts_by_year_returns_sanely
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [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
示例5: create_and_save_200_person_spreadsheet
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def create_and_save_200_person_spreadsheet(self, fields=["first_name","last_name","email","phone_number"], spreadsheet_filename=None):
if not spreadsheet_filename:
spreadsheet_filename = "test.xls"
full_filename = os.path.join(settings.PROJECT_ROOT, TEST_SPREADSHEET_PATH, spreadsheet_filename)
if not os.path.exists(full_filename):
Person.objects_by_account(self.account).all().delete()
[Factory.person(self.account) for f in range(0,200)]
fh = open(full_filename, 'w')
q = Person.objects_by_account(self.account).all()
SpreadsheetAbstraction.create_spreadsheet(q, fields, EXCEL_TYPE, file_handler=fh)
fh.flush()
fh.close()
Person.objects_by_account(self.account).all().delete()
return spreadsheet_filename
示例6: test_donations_by_year_returns_sanely
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [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
示例7: setUp
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def setUp(self, *args, **kwargs):
self.account = self.setup_for_logged_in()
self.people = [Factory.person(self.account) for i in range(1,Factory.rand_int(30,300))]
self.verificationErrors = []
示例8: test_full_contact_list_csv_spreadsheet_with_unicode_200s
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def test_full_contact_list_csv_spreadsheet_with_unicode_200s(self):
p = Factory.person(account=self.a1)
p.last_name = u"O\u2019Brien"
p.save()
self._test_spreadsheet_download_200s_for_template_type(SPREADSHEET_TEMPLATE_CHOICES[0][0], file_type=CSV_TYPE)
示例9: test_completed_shifts_by_year_for_non_volunteer_returns_properly
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [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
示例10: test_donations_by_year_for_non_donors_returns_properly
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def test_donations_by_year_for_non_donors_returns_properly():
person = Factory.person(Factory.create_demo_site("test1", quick=True, delete_existing=True))
target = []
assert person.donor.donations_by_year == target
示例11: test_challenge_has_logged_volunteer_hours
# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import person [as 别名]
def test_challenge_has_logged_volunteer_hours(self):
p = Factory.person(self.a1)
Factory.completed_volunteer_shift(p)
self.a1.check_challenge_progress()
assert self.a1.challenge_has_logged_volunteer_hours == True