chore: formatted stuff
This commit is contained in:
@@ -61,11 +61,11 @@ class TestOrdersAPI(APITestCase, TestUserAuthenticationMixin):
|
||||
"shipping_country": self.customer.country,
|
||||
"shipping_zip": self.customer.zip,
|
||||
"contact_phone": "612345678",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
pk = response.data.get('uuid')
|
||||
pk = response.data.get("uuid")
|
||||
|
||||
response = self.client.get(f"/api/v1/shop/orders/{pk}/")
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
@@ -88,34 +88,36 @@ class TestOrdersAPI(APITestCase, TestUserAuthenticationMixin):
|
||||
"shipping_country": self.customer.country,
|
||||
"shipping_zip": self.customer.zip,
|
||||
"contact_phone": "612345678",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
pk = response.data.get('uuid')
|
||||
pk = response.data.get("uuid")
|
||||
|
||||
response = self.client.get(f"/api/v1/shop/orders/{pk}/")
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert Decimal(response.data.get('base_total')) == Decimal('0.00')
|
||||
assert Decimal(response.data.get('total')) == Decimal('0.00')
|
||||
assert Decimal(response.data.get("base_total")) == Decimal("0.00")
|
||||
assert Decimal(response.data.get("total")) == Decimal("0.00")
|
||||
|
||||
response = self.client.post(
|
||||
f"/api/v1/shop/orders/{pk}/lines/",
|
||||
{
|
||||
"product": self.product.pk,
|
||||
"quantity": "5",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
response = self.client.get(f"/api/v1/shop/orders/{pk}/lines/")
|
||||
assert len(response.data.get('results')) == 1
|
||||
assert len(response.data.get("results")) == 1
|
||||
|
||||
response = self.client.get(f"/api/v1/shop/orders/{pk}/")
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
|
||||
assert Decimal(response.data.get('base_total')) == Decimal('6.00')
|
||||
assert Decimal(response.data.get('total')) == Decimal('6.00') + (Decimal('6.00') * Decimal('0.21'))
|
||||
assert Decimal(response.data.get("base_total")) == Decimal("6.00")
|
||||
assert Decimal(response.data.get("total")) == Decimal("6.00") + (
|
||||
Decimal("6.00") * Decimal("0.21")
|
||||
)
|
||||
|
||||
def test_create_delete_order_with_lines(self):
|
||||
self.login()
|
||||
@@ -136,18 +138,18 @@ class TestOrdersAPI(APITestCase, TestUserAuthenticationMixin):
|
||||
"shipping_country": self.customer.country,
|
||||
"shipping_zip": self.customer.zip,
|
||||
"contact_phone": "612345678",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
pk = response.data.get('uuid')
|
||||
pk = response.data.get("uuid")
|
||||
|
||||
response = self.client.get(f"/api/v1/shop/orders/{pk}/")
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
|
||||
# Assert order is created with 0.00€
|
||||
assert Decimal(response.data.get('base_total')) == Decimal('0.00')
|
||||
assert Decimal(response.data.get('total')) == Decimal('0.00')
|
||||
assert Decimal(response.data.get("base_total")) == Decimal("0.00")
|
||||
assert Decimal(response.data.get("total")) == Decimal("0.00")
|
||||
|
||||
# Create order line
|
||||
response = self.client.post(
|
||||
@@ -155,21 +157,23 @@ class TestOrdersAPI(APITestCase, TestUserAuthenticationMixin):
|
||||
{
|
||||
"product": self.product.pk,
|
||||
"quantity": "5",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
line_pk = response.data.get('id')
|
||||
line_pk = response.data.get("id")
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
response = self.client.get(f"/api/v1/shop/orders/{pk}/lines/")
|
||||
assert len(response.data.get('results')) == 1
|
||||
assert len(response.data.get("results")) == 1
|
||||
|
||||
response = self.client.get(f"/api/v1/shop/orders/{pk}/")
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
|
||||
# Assert order totals are set
|
||||
assert Decimal(response.data.get('base_total')) == Decimal('6.00')
|
||||
assert Decimal(response.data.get('total')) == Decimal('6.00') + (Decimal('6.00') * Decimal('0.21'))
|
||||
assert Decimal(response.data.get("base_total")) == Decimal("6.00")
|
||||
assert Decimal(response.data.get("total")) == Decimal("6.00") + (
|
||||
Decimal("6.00") * Decimal("0.21")
|
||||
)
|
||||
|
||||
# Delete line
|
||||
response = self.client.delete(f"/api/v1/shop/orders/{pk}/lines/{line_pk}/")
|
||||
@@ -179,5 +183,5 @@ class TestOrdersAPI(APITestCase, TestUserAuthenticationMixin):
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
|
||||
# Assert order totals are 0.00
|
||||
assert Decimal(response.data.get('base_total')) == Decimal('0.00')
|
||||
assert Decimal(response.data.get('total')) == Decimal('0.00')
|
||||
assert Decimal(response.data.get("base_total")) == Decimal("0.00")
|
||||
assert Decimal(response.data.get("total")) == Decimal("0.00")
|
||||
|
||||
Reference in New Issue
Block a user