feat: lots of stuff

This commit is contained in:
2024-03-24 20:04:02 +01:00
parent 22cea344a5
commit 7725247a3f
11 changed files with 360 additions and 75 deletions
+21 -2
View File
@@ -1,6 +1,6 @@
from decimal import Decimal
from rest_framework.test import APITestCase as TestCase
from shop.models import Product, ProductPrice, OrderLine, Tax
from shop.models import Product, ProductPrice, OrderLine, Tax, Customer
from shop.utils import create_order_line_for_product, create_order
@@ -34,6 +34,17 @@ class ShopModelsTest(TestCase):
ProductPrice.objects.create(product=self.usb_c, price=Decimal("9.95"))
def test_create_order(self):
self.customer = Customer.objects.create(
first_name='Luke',
last_name='Skywalker',
vat_id='11111111H',
address='Farm Skywalker',
city='Desert',
state='Mos-Eisley',
zip='00001',
country='Tatooine',
)
l1 = create_order_line_for_product(
self.potatoes,
quantity=Decimal("1.5"),
@@ -50,7 +61,15 @@ class ShopModelsTest(TestCase):
tax=self.tax,
)
order = create_order(OrderLine.objects.all())
order = create_order(
customer=self.customer,
lines=OrderLine.objects.all(),
billing_address=self.customer.address,
billing_city=self.customer.city,
billing_state=self.customer.state,
billing_zip=self.customer.zip,
billing_country=self.customer.country,
)
assert order.total == l1.total + l2.total + l3.total
assert order.base_total == l1.base_total + l2.base_total + l3.base_total