예제 #1
0
class TransferTestCase(TestCase):
    fixtures = ['account_details.json']

    def setUp(self):
        self.buyer = GeneralAccountManager().get_or_create_sub_account(
            '10000', 'BUYER', 'PLATFORM', 'ALL', 'CNY')
        self.seller = GeneralAccountManager().get_or_create_sub_account(
            '10001', 'SELLER', 'PLATFORM', 'ALL', 'CNY')

    def test_balance(self):
        self.assertEquals(self.buyer.balance, D('0.00'))
        self.assertEquals(self.seller.balance, D('0.00'))
        self.buyer.balance = D('10.00')
        self.buyer.save()
        self.assertEquals(self.buyer.balance, D('10.00'))

    def test_transfer(self):
        self.buyer.balance = D('10.00')
        self.buyer.save()
        self.assertEquals(self.buyer.balance, D('10.00'))

        Transfer.objects.create_transfer(
            self.buyer, self.seller, D('5.00'), self.buyer)

        self.assertEquals(self.buyer.balance, D('5.00'))
        self.assertEquals(self.seller.balance, D('5.00'))

        t1 = Transaction.objects.get(sub_account=self.buyer)
        t2 = Transaction.objects.get(sub_account=self.seller)

        self.assertEquals(t1.amount, D('-5.00'))
        self.assertEquals(t2.amount, D('5.00'))
예제 #2
0
 def setUp(self):
     self.buyer = GeneralAccountManager().get_or_create_sub_account(
         '10000', 'BUYER', 'PLATFORM', 'ALL', 'CNY')
     self.seller = GeneralAccountManager().get_or_create_sub_account(
         '10001', 'SELLER', 'PLATFORM', 'ALL', 'CNY')