예제 #1
0
    def test_rounding(self):
        """ Rounding test
        300 / 300 = 1 => 1.00000 BTC
        300 / 260 = Decimal('1.153846153846153846153846154') => 1.15385 BTC
        """
        backend = BitcoinBackend(dict(BITCOIN_VALUE=300, URL=''))
        backend.make_rpc = FakeBTCRPCNew
        backend.new_payment(self.p)
        self.assertEqual(self.p.status_message, "Please send 1.00000 BTC to TEST_ADDRESS")

        backend = BitcoinBackend(dict(BITCOIN_VALUE=260, URL=''))
        backend.make_rpc = FakeBTCRPCNew
        backend.new_payment(self.p)
        self.assertEqual(self.p.status_message, "Please send 1.15385 BTC to TEST_ADDRESS")
예제 #2
0
    def test_check_unpaid(self):
        backend = BitcoinBackend(dict(BITCOIN_VALUE=300, URL=''))
        backend.make_rpc = FakeBTCRPCUnpaid

        backend.check(self.p)
        self.assertEqual(self.p.status, 'new')
        self.assertEqual(self.p.paid_amount, 0)
예제 #3
0
    def test_check_unpaid(self):
        backend = BitcoinBackend(dict(URL=''))
        backend.make_rpc = FakeBTCRPCUnpaid

        backend.check(self.p)
        self.assertEqual(self.p.status, 'new')
        self.assertEqual(self.p.paid_amount, 0)
예제 #4
0
    def test_rounding(self):
        """ Rounding test
        300 / 300 = 1 => 1.00000 BTC
        300 / 260 = Decimal('1.153846153846153846153846154') => 1.15385 BTC
        """
        with override_config(BTC_EUR_VALUE=300):
            backend = BitcoinBackend(dict(URL=''))
            backend.make_rpc = FakeBTCRPCNew
            backend.new_payment(self.p)
            self.assertEqual(self.p.status_message,
                             "Please send 1.00000 BTC to TEST_ADDRESS")

        with override_config(BTC_EUR_VALUE=260):
            backend = BitcoinBackend(dict(URL=''))
            backend.make_rpc = FakeBTCRPCNew
            backend.new_payment(self.p)
            self.assertEqual(self.p.status_message,
                             "Please send 1.15385 BTC to TEST_ADDRESS")
예제 #5
0
    def setUp(self):
        self.user = User.objects.create_user('test', '*****@*****.**', None)

        self.p = Payment.objects.create(
            user=self.user, time=timedelta(days=30), backend='bitcoin',
            amount=300)

        # call new_payment
        backend = BitcoinBackend(dict(BITCOIN_VALUE=300, URL=''))
        backend.make_rpc = FakeBTCRPCNew
        backend.new_payment(self.p)
예제 #6
0
    def setUp(self):
        self.user = User.objects.create_user('test', '*****@*****.**',
                                             None)

        self.p = Payment.objects.create(user=self.user,
                                        time=timedelta(days=30),
                                        backend_id='bitcoin',
                                        amount=300)

        # call new_payment
        backend = BitcoinBackend(dict(URL=''))
        backend.make_rpc = FakeBTCRPCNew
        backend.new_payment(self.p)
예제 #7
0
    def test_new(self):
        backend = BitcoinBackend(dict(BITCOIN_VALUE=300, URL=''))
        backend.make_rpc = FakeBTCRPCNew

        backend.new_payment(self.p)
        redirect = backend.new_payment(self.p)
        self.assertEqual(self.p.backend_extid, 'TEST_ADDRESS')
        self.assertEqual(self.p.status, 'new')
        self.assertIn('btc_price', self.p.backend_data)
        self.assertIn('btc_address', self.p.backend_data)
        self.assertEqual(self.p.backend_data['btc_address'], 'TEST_ADDRESS')
        self.assertIsInstance(redirect, HttpResponseRedirect)
        self.assertEqual(redirect.url, '/payments/view/%d' % self.p.id)
        self.assertEqual(self.p.status_message, "Please send 1.00000 BTC to TEST_ADDRESS")
예제 #8
0
    def test_new(self):
        backend = BitcoinBackend(dict(URL=''))
        backend.make_rpc = FakeBTCRPCNew

        backend.new_payment(self.p)
        redirect = backend.new_payment(self.p)
        self.assertEqual(self.p.backend_extid, 'TEST_ADDRESS')
        self.assertEqual(self.p.status, 'new')
        self.assertIn('btc_price', self.p.backend_data)
        self.assertIn('btc_address', self.p.backend_data)
        self.assertEqual(self.p.backend_data['btc_address'], 'TEST_ADDRESS')
        self.assertIsInstance(redirect, HttpResponseRedirect)
        self.assertEqual(redirect.url, '/payments/view/%d' % self.p.id)
        self.assertEqual(self.p.status_message,
                         "Please send 1.00000 BTC to TEST_ADDRESS")
예제 #9
0
 def test_check_paid(self):
     backend = BitcoinBackend(dict(BITCOIN_VALUE=300, URL=''))
     backend.make_rpc = FakeBTCRPCPaid
     backend.check(self.p)
     self.assertEqual(self.p.paid_amount, 300)
     self.assertEqual(self.p.status, 'confirmed')
예제 #10
0
파일: bitcoin.py 프로젝트: CCrypto/ccvpn3
 def test_check_partially_paid(self):
     backend = BitcoinBackend(dict(URL=''))
     backend.make_rpc = FakeBTCRPCPartial
     backend.check(self.p)
     self.assertEqual(self.p.status, 'new')
     self.assertEqual(self.p.paid_amount, 150)
예제 #11
0
 def test_check_paid(self):
     backend = BitcoinBackend(dict(URL=''))
     backend.make_rpc = FakeBTCRPCPaid
     backend.check(self.p)
     self.assertEqual(self.p.paid_amount, 300)
     self.assertEqual(self.p.status, 'confirmed')
예제 #12
0
 def test_check_partially_paid(self):
     backend = BitcoinBackend(dict(URL=''))
     backend.make_rpc = FakeBTCRPCPartial
     backend.check(self.p)
     self.assertEqual(self.p.status, 'new')
     self.assertEqual(self.p.paid_amount, 150)