當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。