本文整理汇总了Python中test_factory.Factory类的典型用法代码示例。如果您正苦于以下问题:Python Factory类的具体用法?Python Factory怎么用?Python Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_a_donation
def add_a_donation(self, amount=None, date=None, type=None, notes=None, in_honor=False, in_memory=False, honorarium_name=None):
sel = self.selenium
self.switch_to_donor_tab()
if not amount:
amount = "%.2f" % (Factory.rand_currency())
if not date:
d = Factory.rand_date()
date = "%02d/%02d/%02d" % (d.month, d.day, d.year)
sel.click("css=tabbed_box[name=add_a_donation] tab_title")
sel.type("css=#id_amount", amount)
sel.type("css=#id_date", date)
if type:
sel.select("css=#id_type",type)
if notes:
sel.type("css=#id_notes", notes)
if in_honor:
sel.click("css=#id_in_honor_of")
if in_memory:
sel.click("css=#id_in_memory_of")
if honorarium_name:
sel.type("css=#id_honorarium_name", honorarium_name)
sel.click("css=tabbed_box[name=add_a_donation] .add_donation_btn")
time.sleep(2)
return amount,date
开发者ID:skoczen,项目名称:mycelium,代码行数:28,代码来源:selenium_abstractions.py
示例2: test_challenge_has_set_up_tags
def test_challenge_has_set_up_tags(self):
# needed since the setup creates some and I don't want to add it to all the other tests.
Tag.objects_by_account(self.a1).delete()
self.a1.check_challenge_progress()
assert self.a1.challenge_has_set_up_tags == False
Factory.tag_person(self.a1)
self.a1.check_challenge_progress()
assert self.a1.challenge_has_set_up_tags == True
开发者ID:skoczen,项目名称:mycelium,代码行数:9,代码来源:unit_tests.py
示例3: test__detect_type
def test__detect_type(self):
fh = Factory.people_mailing_list_spreadsheet_file(self.a1, file_type=CSV_TYPE)
s = SpreadsheetAbstraction(self.a1, fh, "people", filename="test.foo")
self.assertEqual(s.type, CSV_TYPE)
self.assertEqual(s.is_valid,True)
fh = Factory.people_mailing_list_spreadsheet_file(self.a1, file_type=EXCEL_TYPE)
s = SpreadsheetAbstraction(self.a1, fh, "people", filename="test.bar")
self.assertEqual(s.type, EXCEL_TYPE)
self.assertEqual(s.is_valid,True)
开发者ID:skoczen,项目名称:mycelium,代码行数:11,代码来源:unit_tests.py
示例4: test_that_after_signup_users_can_change_their_billing_info
def test_that_after_signup_users_can_change_their_billing_info(self):
# And see it updated.
sel = self.selenium
self.get_logged_in()
self.go_to_the_account_page()
self.enter_billing_info_signup()
assert sel.is_text_present("XXXX-XXXX-XXXX-%s" % (Factory.test_cc_number(True)[-4:]))
self.enter_billing_info_signup(cc_number="4222222222222")
assert not sel.is_text_present("XXXX-XXXX-XXXX-%s" % (Factory.test_cc_number(True)[-4:]))
assert sel.is_text_present("XXXX-XXXX-XXXX-2222")
开发者ID:skoczen,项目名称:mycelium,代码行数:12,代码来源:selenium_tests.py
示例5: test_creating_and_deleting_an_account_does_so_successfully
def test_creating_and_deleting_an_account_does_so_successfully(self):
from django.contrib.auth.models import User
a1 = Factory.create_demo_site("test1", quick=True, create_subscription=True)
a2 = Factory.create_demo_site("test2", quick=True)
a1.delete()
time.sleep(5)
a3 = Factory.create_demo_site("test3", quick=True)
a3.delete()
self.assertEqual(Account.objects.all().count(), 1)
self.assertEqual(User.objects.all().count(), 3)
a2.delete()
self.assertEqual(Account.objects.all().count(), 0)
self.assertEqual(User.objects.all().count(), 0)
开发者ID:skoczen,项目名称:mycelium,代码行数:13,代码来源:unit_tests.py
示例6: test_that_a_new_person_in_account_1_does_not_show_in_account_2_org_people_search
def test_that_a_new_person_in_account_1_does_not_show_in_account_2_org_people_search(self):
sel = self.selenium
cache.clear()
self.go_to_the_login_page()
self.log_in()
self.assert_login_succeeded()
self.create_john_smith_and_verify()
self.create_new_organization()
sel.click("css=tabbed_box tab_title")
time.sleep(0.5)
sel.click("id_search_new_person")
sel.type("id_search_new_person", "john")
time.sleep(2)
assert sel.is_text_present('John Smith')
a2 = self.create_demo_site("test2")
ua = Factory.useraccount(account=a2)
self.set_site("test2")
self.go_to_the_login_page("test2")
self.log_in(ua=ua)
self.assert_login_succeeded()
self.create_new_organization()
sel.click("css=tabbed_box tab_title")
time.sleep(0.5)
sel.click("id_search_new_person")
sel.type("id_search_new_person", "john")
time.sleep(2)
assert sel.is_text_present('No people found for search "john".')
开发者ID:skoczen,项目名称:mycelium,代码行数:30,代码来源:selenium_tests.py
示例7: add_a_conversation
def add_a_conversation(self, body=None, date=None, type="in-person"):
sel = self.selenium
self.switch_to_conversation_tab()
if not body:
body = Factory.rand_str(500)
if not date:
d = Factory.rand_date()
date = "%02d/%02d/%02d" % (d.month, d.day, d.year)
sel.click("css=tabbed_box[name=add_a_conversation] tab_title")
sel.type("css=#id_body", body)
sel.click("css=input[name=conversation_type][value=%s]" % (type,))
sel.type("css=#id_date", date)
sel.click("css=tabbed_box[name=add_a_conversation] .add_conversation_btn")
time.sleep(2)
return body,date
开发者ID:skoczen,项目名称:mycelium,代码行数:16,代码来源:selenium_abstractions.py
示例8: test_num_volunteer_hours
def test_num_volunteer_hours(self):
a = Factory.create_demo_site("test", quick=True)
hours = 0
for c in CompletedShift.objects.all():
hours += c.duration
self.assertEqual(a.num_volunteer_hours, hours)
开发者ID:skoczen,项目名称:mycelium,代码行数:7,代码来源:unit_tests.py
示例9: test_completed_shifts_by_year_returns_sanely
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
开发者ID:skoczen,项目名称:mycelium,代码行数:16,代码来源:unit_tests.py
示例10: created_and_imported_excel_spreadsheet
def created_and_imported_excel_spreadsheet(self, **kwargs):
fh = Factory.people_mailing_list_spreadsheet_file(self.a1, file_type=EXCEL_TYPE, **kwargs)
# import it
fh.seek(0)
s = SpreadsheetAbstraction(self.a1, fh, "people", filename="test.xls")
self.assertEqual(s.is_valid,True)
return s
开发者ID:skoczen,项目名称:mycelium,代码行数:8,代码来源:abstractions.py
示例11: test_challenge_has_added_board
def test_challenge_has_added_board(self):
Factory.tag(self.a1, name="Board of Directors")
bg = Factory.group(self.a1,"board of directors")
Factory.grouprule(self.a1, "have any tag that","contains","Board of Directors", group=bg)
Factory.tag_person(self.a1, tag_name="Board of Directors")
self.a1.check_challenge_progress()
assert self.a1.challenge_has_added_board == True
开发者ID:skoczen,项目名称:mycelium,代码行数:7,代码来源:unit_tests.py
示例12: test_queryset_for_new_group_rule_for_last_volunteer_shift_is_on
def test_queryset_for_new_group_rule_for_last_volunteer_shift_is_on(self):
# create a new group rule (and TagSet)
group, group_rule = self.test_create_new_group_rule_for_last_volunteer_shift_is_on()
# hand-create a few people, some of whom match, and others who don't
ppl = self._generate_people()
target_date = datetime.date(month=3,day=24,year=2010)
Factory.completed_volunteer_shift(ppl[2], date=target_date)
Factory.completed_volunteer_shift(ppl[4], date=target_date)
# assert the queryset string is right
self.assertEqual(group_rule.queryset_filter_string, "filter(volunteer__completedshift__date=datetime.date(month=3,day=24,year=2010))")
# get the queryset, make sure it matches a hand-created one.
qs = group.members
hand_qs = Person.objects_by_account(self.account).filter(Q(pk=ppl[2].pk) | Q(pk=ppl[4].pk) )
self.assertEqualQuerySets(qs,hand_qs)
开发者ID:skoczen,项目名称:mycelium,代码行数:18,代码来源:unit_tests.py
示例13: test_that_new_signups_can_sign_up_for_an_account
def test_that_new_signups_can_sign_up_for_an_account(self):
sel = self.selenium
self.get_logged_in()
self.go_to_the_account_page()
self.enter_billing_info_signup()
assert sel.is_text_present("Status: Free Trial")
assert sel.is_text_present("XXXX-XXXX-XXXX-%s" % (Factory.test_cc_number(True)[-4:]))
assert sel.is_text_present("Signup Date: %s" % (date(datetime.date.today()),) )
assert sel.is_element_present("link=Update Billing Information")
开发者ID:skoczen,项目名称:mycelium,代码行数:10,代码来源:selenium_tests.py
示例14: test_deleting_an_account_cancels_its_subscription
def test_deleting_an_account_cancels_its_subscription(self):
a1 = Factory.create_demo_site("test1", quick=True, create_subscription=True)
stripe_id = a1.stripe_customer_id
c = self.stripe.Customer.retrieve(stripe_id)
assert hasattr(c, "subscription")
a1.delete()
c = self.stripe.Customer.retrieve(stripe_id)
assert not hasattr(c, "subscription")
开发者ID:skoczen,项目名称:mycelium,代码行数:10,代码来源:unit_tests.py
示例15: test_saving_a_blank_group_gives_it_a_filler_name
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)
开发者ID:skoczen,项目名称:mycelium,代码行数:10,代码来源:unit_tests.py
示例16: test_objects_by_account_limits_to_account
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])
开发者ID:skoczen,项目名称:mycelium,代码行数:20,代码来源:unit_tests.py
示例17: test_that_new_donations_can_include_a_type_and_notes
def test_that_new_donations_can_include_a_type_and_notes(self):
sel = self.selenium
self.create_person_and_go_to_donor_tab()
notes_str = Factory.rand_str()
a1, d1 = self.add_a_donation(amount=85.8, date="3/8/2011", type="Check", notes=notes_str)
# make sure recent donations display cleanly
self.assertEqual("$%.2f"%a1, sel.get_text("css=.donor_donation_table .donation_row:nth(0) .amount"))
self.assertEqual("March 8, 2011", sel.get_text("css=.donor_donation_table .donation_row:nth(0) .date"))
self.assertEqual("Check", sel.get_text("css=.donor_donation_table .donation_row:nth(0) .type"))
self.assertEqual("Notes: %s" % notes_str, sel.get_text("css=.donor_donation_table .donation_row:nth(0) .notes_body"))
开发者ID:skoczen,项目名称:mycelium,代码行数:11,代码来源:selenium_tests.py
示例18: add_a_new_shift
def add_a_new_shift(self, hours=None, date=None):
sel = self.selenium
if not hours:
hours = Factory.rand_int(1,10)
sel.click("css=tabbed_box[name=add_a_volunteer_shift] tab_title")
sel.type("css=#id_duration", hours)
if date:
sel.type("css=#id_date", date)
sel.click("css=tabbed_box[name=add_a_volunteer_shift] .add_shift_btn")
time.sleep(2)
开发者ID:skoczen,项目名称:mycelium,代码行数:11,代码来源:selenium_abstractions.py
示例19: test_that_logged_in_site2s_user_cannot_manually_browse_to_site_ones_page
def test_that_logged_in_site2s_user_cannot_manually_browse_to_site_ones_page(self):
sel = self.selenium
a2 = self.create_demo_site("test2")
ua = Factory.useraccount(account=a2)
self.go_to_the_login_page("test2")
self.log_in(ua=ua)
self.assert_login_succeeded()
self.go_to_the_login_page()
self.open("/people")
assert sel.is_element_present("css=.login_btn")
开发者ID:skoczen,项目名称:mycelium,代码行数:11,代码来源:selenium_tests.py
示例20: test_that_requesting_an_invalid_group_404s
def test_that_requesting_an_invalid_group_404s(self):
sel = self.selenium
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,10):
Factory.group(account=self.a1)
self.create_new_group()
# get pk
url = sel.get_location()
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(url, site="test2")
time.sleep(10)
assert sel.is_text_present("not found")
开发者ID:skoczen,项目名称:mycelium,代码行数:20,代码来源:selenium_tests.py
注:本文中的test_factory.Factory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论