当前位置: 首页>>代码示例>>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;未经允许,请勿转载。