feat: reset migrations and created customer address model
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from rest_framework.test import APITestCase as TestCase
|
||||
|
||||
from shop.models import Customer, Product, ProductPrice, Tax
|
||||
from shop.models import Customer, Product, ProductPrice, Tax, CustomerAddress
|
||||
from shop.utils import create_order, create_order_line_for_product
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class ShopModelsTest(TestCase):
|
||||
def setUp(self) -> None:
|
||||
@@ -12,6 +15,33 @@ class ShopModelsTest(TestCase):
|
||||
code="IVA",
|
||||
value=21,
|
||||
)
|
||||
self.customer = User.objects.create_user(
|
||||
username="11111111H",
|
||||
first_name="Darth",
|
||||
last_name="Maull",
|
||||
email="darth@maul.com",
|
||||
password="dathomir",
|
||||
)
|
||||
|
||||
self.customer_shipping_address = CustomerAddress.objects.create(
|
||||
user=self.customer,
|
||||
address="Dathomir",
|
||||
address_town="Dathomir",
|
||||
address_zip="00001",
|
||||
address_state="Dathomir",
|
||||
address_phone="900000000",
|
||||
address_type=CustomerAddress.Types.SHIPPING,
|
||||
)
|
||||
|
||||
self.customer_billing_address = CustomerAddress.objects.create(
|
||||
user=self.customer,
|
||||
address="Dathomir",
|
||||
address_town="Dathomir",
|
||||
address_zip="00001",
|
||||
address_state="Dathomir",
|
||||
address_phone="900000000",
|
||||
address_type=CustomerAddress.Types.BILLING,
|
||||
)
|
||||
self.create_products()
|
||||
|
||||
def create_products(self):
|
||||
@@ -42,24 +72,13 @@ class ShopModelsTest(TestCase):
|
||||
)
|
||||
|
||||
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",
|
||||
)
|
||||
|
||||
order = create_order(
|
||||
customer=self.customer,
|
||||
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,
|
||||
billing_address=self.customer_billing_address.address,
|
||||
billing_city=self.customer_billing_address.address_town,
|
||||
billing_state=self.customer_billing_address.address_state,
|
||||
billing_zip=self.customer_billing_address.address_zip,
|
||||
billing_country=self.customer_billing_address.address_country,
|
||||
)
|
||||
|
||||
l1 = create_order_line_for_product(
|
||||
|
||||
Reference in New Issue
Block a user