🚨 Add pre-commit

Format code
Add bin/run
This commit is contained in:
Nikolai R Kristiansen committed 2022-01-16 22:49:21 +01:00
1 parent 9d3afadbff
commit dcd8edaaa6
28 files changed
+264 -51

No files matched your search

+9 -7
View File
@@ -3,7 +3,7 @@ from django.test import Client
from strawberry.django.test import GraphQLTestClient
from main.api.mutations import create_order
from main.models import Product, Order
from main.models import Order, Product
from main.testing import MutationTest
@@ -12,12 +12,12 @@ def gql_client_fixture(client: Client):
yield GraphQLTestClient(client)
@pytest.fixture(name='product')
@pytest.fixture(name="product")
def product_fix(db):
return Product.objects.create(name='borg', sale_price_ext=35, sale_price_int=30)
return Product.objects.create(name="borg", sale_price_ext=35, sale_price_int=30)
@pytest.fixture(name='create_order_mutation')
@pytest.fixture(name="create_order_mutation")
def create_order_mutation_fixture(product):
fields = """
... on CreateOrderSuccess {
@@ -38,13 +38,15 @@ def create_order_mutation_fixture(product):
def test_create_order(product, create_order_mutation):
assert Order.objects.count() == 0
res = create_order_mutation.mutate(customerId="external", isExternal=True, orderLines=[{"productId": product.id, "amount": 1}])
res = create_order_mutation.mutate(
customerId="external", isExternal=True, orderLines=[{"productId": product.id, "amount": 1}]
)
assert res
assert not res.errors
assert res.data
order_lines = res.data.get('createOrder', {}).get('order', {}).get('orderlines', [])
order_lines = res.data.get("createOrder", {}).get("order", {}).get("orderlines", [])
assert order_lines
assert order_lines[0]['product']['id'] == str(product.id)
assert order_lines[0]["product"]["id"] == str(product.id)
assert Order.objects.count() == 1
o = Order.objects.first()
assert o.orderlines.first().product.id == product.id