Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
chessbr committed Mar 15, 2021
1 parent c08aa4f commit 3092e51
Showing 1 changed file with 17 additions and 3 deletions.
Expand Up @@ -5,26 +5,29 @@
#
# This source code is licensed under the OSL-3.0 license found in the
# LICENSE file in the root directory of this source tree.
from collections import defaultdict

import json
import pytest
import six

from collections import defaultdict

from django.test.client import Client
from django.template import loader

from django.urls import reverse
from shuup.admin.modules.orders.sections import ShipmentSection
from shuup.admin.utils.permissions import set_permissions_for_group
from shuup.core.models import ShippingMode, Supplier, ShipmentStatus
from shuup.testing.factories import (
add_product_to_order, create_empty_order, create_product,
create_random_user, get_default_permission_group, get_default_shop
)
from shuup.admin.modules.orders.views.shipment import ShipmentListView
from shuup.testing.utils import apply_request_middleware


@pytest.mark.django_db
def test_order_shipment_section(rf, admin_user):
def test_order_shipments(rf, admin_user):
shop = get_default_shop()
supplier1 = Supplier.objects.create(identifier="1", name="supplier1")
supplier1.shops.add(shop)
Expand Down Expand Up @@ -153,6 +156,17 @@ def get_quantity(supplier, product):
# We still should see the order shipment section since existing shipments
assert ShipmentSection.visible_for_object(order, request)

# list all shipments in shipments list view
response = client.get("{}?jq={}".format(
reverse("shuup_admin:order.shipments.list"),
json.dumps({"perPage": 10, "page": 1})
))
assert response.status_code == 200
data = json.loads(response.content)
assert len(data["items"]) == 3
for item in data["items"]:
assert item["status"] == "Sent"

# Let's delete all shipments since both products is unshipped and we
# don't need those.
for shipment in order.shipments.all():
Expand Down

0 comments on commit 3092e51

Please sign in to comment.