當前位置: 首頁>>代碼示例>>Python>>正文


Python test_factory.Factory類代碼示例

本文整理匯總了Python中test_factory.Factory的典型用法代碼示例。如果您正苦於以下問題:Python Factory類的具體用法?Python Factory怎麽用?Python Factory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Factory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的test_factory.Factory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。