예제 #1
0
class TestANewZeroCreditLimitAccount(TestCase):
    def setUp(self):
        self.account = Account()

    def test_defaults_to_zero_credit_limit(self):
        self.assertEqual(D('0.00'), self.account.credit_limit)

    def test_does_not_permit_any_debits(self):
        self.assertFalse(self.account.is_debit_permitted(D('1.00')))

    def test_has_zero_balance(self):
        self.assertEqual(D('0.00'), self.account.balance)

    def test_has_zero_transactions(self):
        self.assertEqual(0, self.account.num_transactions())
class TestANewZeroCreditLimitAccount(TestCase):

    def setUp(self):
        self.account = Account()

    def test_defaults_to_zero_credit_limit(self):
        self.assertEqual(D('0.00'), self.account.credit_limit)

    def test_does_not_permit_any_debits(self):
        self.assertFalse(self.account.is_debit_permitted(D('1.00')))

    def test_has_zero_balance(self):
        self.assertEqual(D('0.00'), self.account.balance)

    def test_has_zero_transactions(self):
        self.assertEqual(0, self.account.num_transactions())
예제 #3
0
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)
예제 #4
0
class TestAnAccountWithFundsButOnlyForProducts(TestCase):
    def setUp(self):
        self.account = Account()
        self.account.can_be_used_for_non_products = False
        self.account.balance = D('100.00')

    def test_doesnt_allow_shipping_in_allocation(self):
        amt = self.account.permitted_allocation(None, D('20.00'), D('40.00'))
        self.assertEqual(D('20.00'), amt)
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)
class TestAnAccountWithFundsButOnlyForProducts(TestCase):

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

    def test_doesnt_allow_shipping_in_allocation(self):
        amt = self.account.permitted_allocation(
            None, D('20.00'), D('40.00'))
        self.assertEqual(D('20.00'), amt)
예제 #7
0
 def setUp(self):
     self.account = Account()
예제 #8
0
 def setUp(self):
     self.account = Account()
     self.account.can_be_used_for_non_products = False
     self.account.balance = D('100.00')
예제 #9
0
 def setUp(self):
     self.account = Account()
     self.account.balance = D('100.00')
예제 #10
0
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.assertEqual('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 = UserFactory()
        self.assertTrue(self.account.can_be_authorised_by(user))

    def test_can_only_be_authorised_by_primary_user_when_set(self):
        primary = UserFactory()
        other = UserFactory()
        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 = [UserFactory(), UserFactory()]
        other = UserFactory()
        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)
 def setUp(self):
     self.account = Account()
     self.account.can_be_used_for_non_products = False
     self.account.balance = D('100.00')
 def setUp(self):
     self.account = Account()
     self.account.balance = D('100.00')
 def setUp(self):
     self.account = Account()
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 = UserFactory()
        self.assertTrue(self.account.can_be_authorised_by(user))

    def test_can_only_be_authorised_by_primary_user_when_set(self):
        primary = UserFactory()
        other = UserFactory()
        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 = [UserFactory(), UserFactory()]
        other = UserFactory()
        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)