2016-03-27 08:25:24 +00:00
|
|
|
import pytz
|
|
|
|
|
2017-04-22 08:39:07 +00:00
|
|
|
from registrasion.tests.controller_helpers import TestingCartController
|
|
|
|
from registrasion.tests.controller_helpers import TestingInvoiceController
|
2016-03-27 08:25:24 +00:00
|
|
|
|
2017-04-22 08:39:07 +00:00
|
|
|
from registrasion.tests.test_cart import RegistrationCartTestCase
|
2016-03-27 08:25:24 +00:00
|
|
|
|
2016-04-25 04:31:25 +00:00
|
|
|
from registrasion.models import commerce
|
|
|
|
|
2016-03-27 08:25:24 +00:00
|
|
|
UTC = pytz.timezone('UTC')
|
|
|
|
|
|
|
|
|
|
|
|
class RefundTestCase(RegistrationCartTestCase):
|
|
|
|
|
|
|
|
def test_refund_marks_void_and_unpaid_and_cart_released(self):
|
2016-04-03 00:06:35 +00:00
|
|
|
current_cart = TestingCartController.for_user(self.USER_1)
|
2016-03-27 08:25:24 +00:00
|
|
|
|
|
|
|
# Should be able to create an invoice after the product is added
|
|
|
|
current_cart.add_to_cart(self.PROD_1, 1)
|
2016-04-07 00:23:38 +00:00
|
|
|
invoice = TestingInvoiceController.for_cart(current_cart.cart)
|
2016-03-27 08:25:24 +00:00
|
|
|
|
|
|
|
invoice.pay("A Payment!", invoice.invoice.value)
|
2016-04-06 22:28:43 +00:00
|
|
|
self.assertFalse(invoice.invoice.is_void)
|
|
|
|
self.assertTrue(invoice.invoice.is_paid)
|
|
|
|
self.assertFalse(invoice.invoice.is_refunded)
|
2016-04-25 04:31:25 +00:00
|
|
|
self.assertNotEqual(
|
|
|
|
commerce.Cart.STATUS_RELEASED,
|
|
|
|
invoice.invoice.cart.status,
|
|
|
|
)
|
2016-03-27 08:25:24 +00:00
|
|
|
|
2016-04-10 04:41:43 +00:00
|
|
|
invoice.refund()
|
2016-04-06 22:28:43 +00:00
|
|
|
self.assertFalse(invoice.invoice.is_void)
|
|
|
|
self.assertFalse(invoice.invoice.is_paid)
|
|
|
|
self.assertTrue(invoice.invoice.is_refunded)
|
2016-04-25 04:31:25 +00:00
|
|
|
self.assertEqual(
|
|
|
|
commerce.Cart.STATUS_RELEASED,
|
|
|
|
invoice.invoice.cart.status,
|
|
|
|
)
|