当前位置: 首页>>代码示例>>Python>>正文


Python Factory.account方法代码示例

本文整理汇总了Python中test_factory.Factory.account方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.account方法的具体用法?Python Factory.account怎么用?Python Factory.account使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test_factory.Factory的用法示例。


在下文中一共展示了Factory.account方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_saving_a_blank_group_gives_it_a_filler_name

# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
 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,代码行数:12,代码来源:unit_tests.py

示例2: test_objects_by_account_limits_to_account

# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
    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,代码行数:22,代码来源:unit_tests.py

示例3: test_completed_shifts_by_year_returns_sanely

# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [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
开发者ID:skoczen,项目名称:mycelium,代码行数:18,代码来源:unit_tests.py

示例4: test_donations_by_year_returns_sanely

# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [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
开发者ID:skoczen,项目名称:mycelium,代码行数:25,代码来源:unit_tests.py

示例5: setUp

# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [as 别名]
 def setUp(self):
     self.account = Factory.account()
     populate_rule_components_for_an_account(self.account)
     self.request = Dummy()
     self.request.account = self.account
开发者ID:skoczen,项目名称:mycelium,代码行数:7,代码来源:unit_tests.py

示例6: test_completed_shifts_by_year_for_non_volunteer_returns_properly

# 需要导入模块: from test_factory import Factory [as 别名]
# 或者: from test_factory.Factory import account [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
开发者ID:skoczen,项目名称:mycelium,代码行数:7,代码来源:unit_tests.py


注:本文中的test_factory.Factory.account方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。