Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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')
Ejemplo n.º 10
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)
Ejemplo n.º 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')
Ejemplo n.º 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)