本文整理汇总了Python中accounts.models.Account.can_be_authorised_by方法的典型用法代码示例。如果您正苦于以下问题:Python Account.can_be_authorised_by方法的具体用法?Python Account.can_be_authorised_by怎么用?Python Account.can_be_authorised_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.Account
的用法示例。
在下文中一共展示了Account.can_be_authorised_by方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestAnAccount
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import can_be_authorised_by [as 别名]
class TestAnAccount(TestCase):
def setUp(self):
self.account = Account()
def test_is_open_by_default(self):
self.assertEqual(Account.OPEN, self.account.status)
def test_can_be_closed(self):
self.account.close()
self.assertEqual(Account.CLOSED, self.account.status)
def test_always_saves_the_code_as_uppercase(self):
self.account.code = 'abc'
self.account.save()
self.assertEquals('ABC', self.account.code)
def test_can_be_authorised_when_no_user_passed(self):
self.assertTrue(self.account.can_be_authorised_by())
def test_can_be_authorised_by_anyone_by_default(self):
self.account.save()
user = G(User)
self.assertTrue(self.account.can_be_authorised_by(user))
def test_can_only_be_authorised_by_primary_user_when_set(self):
primary = G(User)
other = G(User)
self.account.primary_user = primary
self.account.save()
self.assertTrue(self.account.can_be_authorised_by(primary))
self.assertFalse(self.account.can_be_authorised_by(other))
def test_can_only_be_authorised_by_secondary_users_when_set(self):
self.account.save()
users = [G(User), G(User)]
other = G(User)
for user in users:
self.account.secondary_users.add(user)
for user in users:
self.assertTrue(self.account.can_be_authorised_by(user))
self.assertFalse(self.account.can_be_authorised_by(other))
def test_does_not_permit_an_allocation(self):
amt = self.account.permitted_allocation(
None, D('2.00'), D('12.00'))
self.assertEqual(D('0.00'), amt)