Skip to content

Commit 7fabeef

Browse files
committed
Fix tests
1 parent 673938b commit 7fabeef

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-5
lines changed

example/tests/admin/test_admin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from salesman.admin import admin
77
from salesman.conf import app_settings
88
from salesman.core.utils import get_salesman_model
9+
from shop.models import Product
910

1011
site = AdminSite()
1112

@@ -22,8 +23,9 @@ def test_order_item_inline(rf, django_user_model):
2223
)
2324
modeladmin = admin.OrderItemInline(OrderItem, site)
2425
order = Order.objects.create(ref="1")
26+
product = Product.objects.create(name="Test", price=10)
2527
item = OrderItem.objects.create(
26-
order=order, unit_price=10, subtotal=20, total=20, quantity=2
28+
order=order, product=product, unit_price=10, subtotal=20, total=20, quantity=2
2729
)
2830
modeladmin.get_queryset(request)
2931
assert modeladmin.model.request == request

example/tests/admin/test_admin_mixins.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from salesman.admin.wagtail.mixins import WagtailOrderAdminMixin
1111
from salesman.conf import app_settings
1212
from salesman.core.utils import get_salesman_model
13+
from shop.models import Product
1314

1415
site = AdminSite()
1516

@@ -35,8 +36,10 @@ def test_order_item_admin_mixin():
3536
order = Order.objects.create(ref="1")
3637
extra = {"test": "123", "rows": ["value"]}
3738
product_data = {"name": "Test product"}
39+
product = Product.objects.create(name="Test Product", price=10)
3840
item = OrderItem.objects.create(
3941
order=order,
42+
product=product,
4043
unit_price=10,
4144
subtotal=20,
4245
total=20,

example/tests/admin/test_admin_panels.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from salesman.admin.wagtail.forms import WagtailOrderModelForm
1818
from salesman.admin.wagtail_hooks import OrderAdmin
1919
from salesman.core.utils import get_salesman_model
20+
from shop.models import Product
2021

2122
Order = get_salesman_model("Order")
2223
OrderItem = get_salesman_model("OrderItem")
@@ -117,8 +118,9 @@ def test_order_checkbox_panel():
117118
@pytest.mark.django_db
118119
def test_order_items_panel():
119120
order = Order.objects.create(ref="1", subtotal=120, total=120)
121+
product = Product.objects.create(name="Test Product", price=50)
120122
OrderItem.objects.create(
121-
order=order, unit_price=50, subtotal=100, total=120, quantity=2
123+
order=order, product=product, unit_price=50, subtotal=100, total=120, quantity=2
122124
)
123125
panel = OrderItemsPanel("items")
124126
panel.model = Order

example/tests/admin/test_admin_wagtail_hooks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from salesman.admin import wagtail_hooks
77
from salesman.core.utils import get_salesman_model
8+
from shop.models import Product
89

910
site = AdminSite()
1011

@@ -21,10 +22,13 @@ def test_order_admin(rf, client, django_user_model):
2122
request.session = {}
2223
request._messages = FallbackStorage(request)
2324
order = Order.objects.create(ref="2020-00001", subtotal=100, total=120)
25+
product = Product.objects.create(name="Test Product", price=100)
2426
OrderItem.objects.create(
25-
order=order, unit_price=10, subtotal=20, total=20, quantity=2
27+
order=order, product=product, unit_price=10, subtotal=20, total=20, quantity=2
28+
)
29+
OrderItem.objects.create(
30+
order=order, product=product, unit_price=1, subtotal=2, total=2, quantity=1
2631
)
27-
OrderItem.objects.create(order=order, unit_price=1, subtotal=2, total=2, quantity=1)
2832
modeladmin = wagtail_hooks.OrderAdmin()
2933
modeladmin.model = Order
3034
modeladmin.model.request = request

example/tests/orders/test_orders_views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_order_views(django_user_model):
3434
)
3535
OrderItem.objects.create(
3636
order=order2,
37+
product=product,
3738
product_data={"name": "Test data"},
3839
unit_price=70,
3940
subtotal=70,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ djangorestframework = ">=3.11,<3.15"
3535

3636
# Optional
3737
Pygments = {version = "^2.6", optional = true}
38-
wagtail = {version = ">=2.9,<5.0", optional = true}
38+
wagtail = {version = ">=2.9,<4.2", optional = true}
3939
pytest = {version = "~7.0.0", optional = true}
4040
pytest-django = {version = "~4.5.0", optional = true}
4141
pytest-cov = {version = "~3.0.0", optional = true}

0 commit comments

Comments
 (0)