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


Python Account.close方法代碼示例

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


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

示例1: TestAnAccountWithFunds

# 需要導入模塊: from accounts.models import Account [as 別名]
# 或者: from accounts.models.Account import close [as 別名]
class TestAnAccountWithFunds(TestCase):

    def setUp(self):
        self.account = Account()
        self.account.balance = D('100.00')

    def test_cannot_be_closed(self):
        with self.assertRaises(exceptions.AccountNotEmpty):
            self.account.close()
開發者ID:a-musing-moose,項目名稱:django-oscar-accounts,代碼行數:11,代碼來源:model_tests.py

示例2: TestAnAccount

# 需要導入模塊: from accounts.models import Account [as 別名]
# 或者: from accounts.models.Account import close [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)
開發者ID:Jyggafey,項目名稱:django-oscar-accounts,代碼行數:51,代碼來源:model_tests.py

示例3: TestAnAccountWithFunds

# 需要導入模塊: from accounts.models import Account [as 別名]
# 或者: from accounts.models.Account import close [as 別名]
class TestAnAccountWithFunds(TestCase):

    def setUp(self):
        self.account = Account()
        self.account.balance = D('100.00')

    def test_cannot_be_closed(self):
        with self.assertRaises(exceptions.AccountNotEmpty):
            self.account.close()

    def test_allows_allocations_less_than_balance(self):
        amt = self.account.permitted_allocation(
            None, D('2.00'), D('12.00'))
        self.assertEqual(D('12.00'), amt)

    def test_doesnt_allow_allocations_greater_than_balance(self):
        amt = self.account.permitted_allocation(
            None, D('2.00'), D('120.00'))
        self.assertEqual(D('100.00'), amt)
開發者ID:Jyggafey,項目名稱:django-oscar-accounts,代碼行數:21,代碼來源:model_tests.py


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