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


Python Factory.create_demo_site方法代碼示例

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


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

示例1: test_creating_and_deleting_an_account_does_so_successfully

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 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,代碼行數:15,代碼來源:unit_tests.py

示例2: test_num_volunteer_hours

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
    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,代碼行數:9,代碼來源:unit_tests.py

示例3: test_deleting_an_account_cancels_its_subscription

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
    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,代碼行數:12,代碼來源:unit_tests.py

示例4: test_factory_account_can_be_run_multiple_times

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
    def test_factory_account_can_be_run_multiple_times(self):
        for i in range(0,Factory.rand_int(2,6)):
            Factory.create_demo_site("test%s" % i, quick=True)

        assert True == True # Finished successfully.        
開發者ID:skoczen,項目名稱:mycelium,代碼行數:7,代碼來源:unit_tests.py

示例5: setUp

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def setUp(self):
     self.signal_kwargs = None
     self.account = Factory.create_demo_site("test1", quick=True, create_subscription=True)
     mail.outbox = []
開發者ID:skoczen,項目名稱:mycelium,代碼行數:6,代碼來源:unit_tests.py

示例6: test_num_spreadsheets

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def test_num_spreadsheets(self):
     a = Factory.create_demo_site("test", quick=True)
     self.assertEqual(a.num_spreadsheets, Spreadsheet.objects_by_account(a).count())
開發者ID:skoczen,項目名稱:mycelium,代碼行數:5,代碼來源:unit_tests.py

示例7: create_demo_site

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def create_demo_site(self, name="test", mostly_empty=False, **kwargs):
     return Factory.create_demo_site(name, quick=True, delete_existing=True,  mostly_empty=mostly_empty, create_subscription=True, **kwargs)
開發者ID:skoczen,項目名稱:mycelium,代碼行數:4,代碼來源:selenium_abstractions.py

示例8: test_donations_by_year_for_non_donors_returns_properly

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [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
開發者ID:skoczen,項目名稱:mycelium,代碼行數:7,代碼來源:unit_tests.py

示例9: test_by_the_numbers_numbers

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
    def test_by_the_numbers_numbers(self):
        # test against hand-counted queries
        from dashboard.views import _account_numbers_dict
        a1 = Factory.create_demo_site("test2", quick=True)

        nums = _account_numbers_dict(a1)

        start_of_this_year = datetime.date(month=1, day=1, year=datetime.date.today().year)
        
        # total_donations
        total_donations_hand_count = 0
        for d in Donation.objects.all():
            if d.account == a1 and d.date >= start_of_this_year:
                total_donations_hand_count += 1
        self.assertEqual(Decimal(nums["total_donations"]), Decimal(total_donations_hand_count))
        

        # total_donors
        total_donors_hand_count = 0
        donors_list = []
        for d in Donation.objects.all():
            if d.account == a1 and d.date >= start_of_this_year:
                if d.donor not in donors_list:
                    total_donors_hand_count += 1
                    donors_list.append(d.donor)
        self.assertEqual(nums["total_donors"], total_donors_hand_count)


        # total donation amount
        total_donation_amount_hand_count = 0
        for d in Donation.objects.all():
            if d.account == a1 and d.date >= start_of_this_year:
                total_donation_amount_hand_count += d.amount

        self.assertEqual(nums["total_donation_amount"], total_donation_amount_hand_count)
        
        # average
        nums_avg = "%f" % nums["average_donation"]
        if total_donations_hand_count == 0:
            calc_avg = "%f" % 0.0
        else:
            calc_avg = "%f" % (total_donation_amount_hand_count/total_donations_hand_count)
        nums_avg = nums_avg[:-2]
        calc_avg = calc_avg[:-2]
        self.assertEqual(nums_avg, calc_avg )   
        
        # total_volunteer_hours
        total_volunteer_hours_hand_count = 0
        for d in CompletedShift.objects.all():
            if d.account == a1 and d.date >= start_of_this_year:
                total_volunteer_hours_hand_count += d.duration

        self.assertEqual(nums["total_volunteer_hours"], total_volunteer_hours_hand_count)

        # total_people
        total_people = 0
        for d in Person.objects.all():
            if d.account == a1:
                total_people += 1

        self.assertEqual(nums["total_people"], total_people)

        # total_orgs
        total_orgs = 0
        for d in Organization.objects.all():
            if d.account == a1:
                total_orgs += 1

        self.assertEqual(nums["total_orgs"], total_orgs)

        # total_groups
        total_groups = 0
        for d in Group.objects.all():
            if d.account == a1:
                total_groups += 1

        for d in TagGroup.objects.all():
            if d.account == a1:
                total_groups += 1
        
        self.assertEqual(nums["total_groups"], total_groups)

        # total_tags 
        total_tags = 0
        for d in Tag.objects.all():
            if d.account == a1:
                total_tags += 1

        self.assertEqual(nums["total_tags"], total_tags)

        # total_taggeditems
        total_taggeditems = 0
        for d in TaggedItem.objects.all():
            if d.account == a1:
                total_taggeditems += 1

        self.assertEqual(nums["total_taggeditems"], total_taggeditems)
開發者ID:skoczen,項目名稱:mycelium,代碼行數:99,代碼來源:unit_tests.py

示例10: test_avg_donation

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def test_avg_donation(self):
     a = Factory.create_demo_site("test", quick=True)
     self.assertEqual(a.avg_donation, float(a.total_donations) / a.num_donations_denominator)
開發者ID:skoczen,項目名稱:mycelium,代碼行數:5,代碼來源:unit_tests.py

示例11: test_total_donations

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def test_total_donations(self):
     a = Factory.create_demo_site("test", quick=True)
     total = 0
     for d in Donation.objects_by_account(a).all():
         total += d.amount
     self.assertEqual(a.total_donations, total)
開發者ID:skoczen,項目名稱:mycelium,代碼行數:8,代碼來源:unit_tests.py

示例12: test_num_donations_denominator

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def test_num_donations_denominator(self):
     a = Factory.create_demo_site("test", quick=True)
     if Donation.objects_by_account(a).count() > 0:
         self.assertEqual(a.num_donations_denominator, Donation.objects_by_account(a).count())
     else:
         self.assertEqual(a.num_donations_denominator,1)
開發者ID:skoczen,項目名稱:mycelium,代碼行數:8,代碼來源:unit_tests.py

示例13: test_num_donations

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def test_num_donations(self):
     a = Factory.create_demo_site("test", quick=True)
     self.assertEqual(a.num_donations, Donation.objects_by_account(a).count())
開發者ID:skoczen,項目名稱:mycelium,代碼行數:5,代碼來源:unit_tests.py

示例14: test_num_people_denominator

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def test_num_people_denominator(self):
     a = Factory.create_demo_site("test", quick=True)
     if Person.objects_by_account(a).count() > 0:
         self.assertEqual(a.num_people, Person.objects_by_account(a).count())
     else:
         self.assertEqual(a.num_people,1)
開發者ID:skoczen,項目名稱:mycelium,代碼行數:8,代碼來源:unit_tests.py

示例15: test_num_people

# 需要導入模塊: from test_factory import Factory [as 別名]
# 或者: from test_factory.Factory import create_demo_site [as 別名]
 def test_num_people(self):
     a = Factory.create_demo_site("test", quick=True)
     self.assertEqual(a.num_people, Person.objects_by_account(a).count())
開發者ID:skoczen,項目名稱:mycelium,代碼行數:5,代碼來源:unit_tests.py


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