• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factories.create_random_order函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shuup.testing.factories.create_random_order函数的典型用法代码示例。如果您正苦于以下问题:Python create_random_order函数的具体用法?Python create_random_order怎么用?Python create_random_order使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_random_order函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_mass_edit_orders3

def test_mass_edit_orders3(rf, admin_user):
    shop = get_default_shop()
    supplier = get_default_supplier()
    contact1 = create_random_person()
    product1 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="50")
    product2 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="501")

    order1 = create_random_order(customer=contact1,
                                products=[product1, product2],
                                completion_probability=0)

    order2 = create_random_order(customer=contact1,
                                products=[product1, product2],
                                completion_probability=0)
    assert order1.status.role != OrderStatusRole.CANCELED
    assert order2.status.role != OrderStatusRole.CANCELED

    payload = {
        "action": OrderConfirmationPdfAction().identifier,
        "values": [order1.pk, order2.pk]
    }
    request = apply_request_middleware(rf.post(
        "/",
        user=admin_user,
    ))
    request._body = json.dumps(payload).encode("UTF-8")
    view = OrderListView.as_view()
    response = view(request=request)
    assert response.status_code == 200
    if weasyprint:
        assert response['Content-Disposition'] == 'attachment; filename=order_confirmation_pdf.zip'
    else:
        assert response["content-type"] == "application/json"
开发者ID:gurch101,项目名称:shuup,代码行数:33,代码来源:test_order_mass_actions.py


示例2: test_list_orders

def test_list_orders(admin_user):
    shop = get_default_shop()
    product = create_product("test", shop, get_default_supplier())
    order = create_random_order(get_person_contact(admin_user), [product])
    order2 = create_random_order(create_random_person(), [product])
    client = _get_client(admin_user)
    response = client.get("/api/shuup/front/orders/")
    response_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert len(response_data) == 1
    assert "shop" in response_data[0]
    assert "contact_address" in response_data[0]["shop"]
开发者ID:ruqaiya,项目名称:shuup,代码行数:12,代码来源:test_front_orders_api.py


示例3: test_get_shipments

def test_get_shipments(admin_user):
    client = _get_client(admin_user)
    shop1 = get_shop(True)
    shop2 = get_shop(True)
    customer1 = create_random_person()
    customer2 = create_random_person()
    order1 = create_random_order(customer1, shop=shop1, completion_probability=1)
    order2 = create_random_order(customer2, shop=shop1, completion_probability=1)
    order3 = create_random_order(customer1, shop=shop2, completion_probability=1)
    order4 = create_random_order(customer2, shop=shop1, completion_probability=1)

    # list shipments
    response = client.get("/api/shuup/shipment/")
    assert response.status_code == status.HTTP_200_OK
    shipment_data = json.loads(response.content.decode("utf-8"))
    assert len(shipment_data) == 4
    assert shipment_data[0]["id"] == order1.shipments.first().pk
    assert shipment_data[1]["id"] == order2.shipments.first().pk
    assert shipment_data[2]["id"] == order3.shipments.first().pk
    assert shipment_data[3]["id"] == order4.shipments.first().pk

    # get shipment by id
    response = client.get("/api/shuup/shipment/%s/" % order1.shipments.first().pk)
    assert response.status_code == status.HTTP_200_OK
    shipment_data = json.loads(response.content.decode("utf-8"))
    assert shipment_data["id"] == order1.shipments.first().pk
    assert shipment_data["order"] == order1.pk

    # get shipment by product
    product = order2.shipments.first().products.first()
    response = client.get("/api/shuup/shipment/?product=%s" % product.pk)
    assert response.status_code == status.HTTP_200_OK
    shipment_data = json.loads(response.content.decode("utf-8"))
    for ship in shipment_data:
        for ship_product in shipment_data["product"]:
            assert ship_product["id"] == product.pk
            assert ship_product["order"] == order2.pk

    # get shipment by order
    response = client.get("/api/shuup/shipment/?order=%s" % order3.pk)
    assert response.status_code == status.HTTP_200_OK
    shipment_data = json.loads(response.content.decode("utf-8"))
    for ship in shipment_data:
        assert ship["order"] == order3.pk

    # get shipment by shop
    response = client.get("/api/shuup/shipment/?shop=%s" % shop1.pk)
    assert response.status_code == status.HTTP_200_OK
    shipment_data = json.loads(response.content.decode("utf-8"))
    for ship in shipment_data:
        assert Shipment.objects.filter(pk=ship["id"], order__shop=shop1).exists()
开发者ID:gurch101,项目名称:shuup,代码行数:51,代码来源:test_shipments_api.py


示例4: test_order_received

def test_order_received(rf, regular_user):
    activate("en")
    get_default_product()
    get_default_supplier()
    get_test_script("test script", "order_received")

    template_data = STEP_DATA[0]["actions"][0]["template_data"]
    for lang in ["en", "fi"]:
        n_outbox_pre = len(mail.outbox)
        customer = create_random_person(locale=lang)
        create_random_order(customer)
        assert (len(mail.outbox) == n_outbox_pre + 1), "Sending email failed"
        latest_mail = mail.outbox[-1]
        assert latest_mail.subject == template_data[lang]["subject"], "Subject doesn't match"
        assert latest_mail.body == template_data[lang]["body"], "Body doesn't match"
开发者ID:ruqaiya,项目名称:shuup,代码行数:15,代码来源:test_order_notifications.py


示例5: test_retrieve_order

def test_retrieve_order(admin_user):
    shop = get_default_shop()
    product = create_product("test", shop, get_default_supplier())
    order = create_random_order(get_person_contact(admin_user), [product])
    order2 = create_random_order(create_random_person(), [product])
    client = _get_client(admin_user)
    response = client.get("/api/shuup/front/orders/{}/".format(order.pk))
    response_data = json.loads(response.content.decode("utf-8"))
    assert response.status_code == status.HTTP_200_OK
    assert response_data["id"] == order.pk

    response = client.get("/api/shuup/front/orders/{}/".format(100))
    assert response.status_code == 404

    response = client.get("/api/shuup/front/orders/{}/".format(order2.pk))
    assert response.status_code == 404
开发者ID:suutari-ai,项目名称:shuup,代码行数:16,代码来源:test_front_orders_api.py


示例6: test_mass_edit_orders

def test_mass_edit_orders(rf, admin_user):
    shop = get_default_shop()
    supplier = get_default_supplier()
    contact1 = create_random_person()
    product1 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="50")
    product2 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="501")

    order = create_random_order(customer=contact1,
                                products=[product1, product2],
                                completion_probability=0)

    assert order.status.role != OrderStatusRole.CANCELED
    payload = {
        "action": CancelOrderAction().identifier,
        "values": [order.pk]
    }
    request = apply_request_middleware(rf.post(
        "/",
        user=admin_user,
    ))
    request._body = json.dumps(payload).encode("UTF-8")
    view = OrderListView.as_view()
    response = view(request=request)
    assert response.status_code == 200
    for order in Order.objects.all():
        assert order.status.role == OrderStatusRole.CANCELED
开发者ID:gurch101,项目名称:shuup,代码行数:26,代码来源:test_order_mass_actions.py


示例7: test_delete_payment

def test_delete_payment(admin_user, rf):
    product = get_default_product()
    shop_product = product.get_shop_instance(get_default_shop())
    shop_product.default_price_value = 20
    shop_product.save()

    order = create_random_order(customer=create_random_person(), products=(product,), completion_probability=0)
    payment_amount = order.taxful_total_price_value

    # create a payment
    view = OrderCreatePaymentView.as_view()
    request = apply_request_middleware(rf.post("/", {"amount": payment_amount}), user=admin_user)
    response = view(request, pk=order.pk)
    assert response.status_code == 302

    order.refresh_from_db()
    assert order.is_paid()

    # delete the payment
    payment = order.payments.last()
    view = OrderDeletePaymentView.as_view()
    request = apply_request_middleware(rf.post("/", {"payment": payment.pk}), user=admin_user)
    response = view(request, pk=order.pk)
    assert response.status_code == 302

    order.refresh_from_db()
    assert order.is_not_paid()
开发者ID:ruqaiya,项目名称:shuup,代码行数:27,代码来源:test_order_module.py


示例8: test_order_creator_customer_details

def test_order_creator_customer_details(rf, admin_user):
    shop = get_default_shop()
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    company = create_random_company()
    group = get_default_customer_group()
    contact.groups.add(group)
    contact.company_memberships.add(company)
    contact.save()
    product = create_product(sku=printable_gibberish(), supplier=get_default_supplier(), shop=shop)
    order = create_random_order(contact, products=[product])
    request = apply_request_middleware(rf.get("/", {"command": "customer_details", "id": contact.id}), user=admin_user)
    response = OrderEditView.as_view()(request)
    data = json.loads(response.content.decode("utf8"))

    assert "customer_info" in data
    assert "order_summary" in data
    assert "recent_orders" in data
    assert data["customer_info"]["name"] == contact.full_name
    assert data["customer_info"]["phone_no"] == contact.phone
    assert data["customer_info"]["email"] == contact.email
    assert company.full_name in data["customer_info"]["companies"]
    assert group.name in data["customer_info"]["groups"]
    assert data["customer_info"]["merchant_notes"] == contact.merchant_notes
    assert len(data["order_summary"]) == 1
    assert data["order_summary"][0]["year"] == order.order_date.year
    assert data["order_summary"][0]["total"] == format_money(order.taxful_total_price)
    assert len(data["recent_orders"]) == 1
    assert data["recent_orders"][0]["status"] == order.get_status_display()
    assert data["recent_orders"][0]["total"] == format_money(order.taxful_total_price)
    assert data["recent_orders"][0]["payment_status"] == force_text(order.payment_status.label)
    assert data["recent_orders"][0]["shipment_status"] == force_text(order.shipping_status.label)
开发者ID:suutari,项目名称:shoop,代码行数:31,代码来源:test_order_creator.py


示例9: test_coupon_amount_limit

def test_coupon_amount_limit():
    coupon = Coupon.objects.create(code="TEST", active=True)
    get_default_campaign(coupon)

    contact = create_random_person()
    shop = get_default_shop()
    product = create_product("test", shop=shop, supplier=get_default_supplier(), default_price="12")
    order = create_random_order(customer=contact)

    for x in range(50):
       coupon.use(order)

    assert coupon.usages.count() == 50
    coupon.increase_usage_limit_by(5)
    coupon.save()

    assert coupon.usage_limit == 55
    assert coupon.can_use_code(contact)

    for x in range(5):
        coupon.use(order)

    assert coupon.usages.count() == 55

    assert not Coupon.is_usable(coupon.code, order.customer)
    assert coupon.usages.count() == 55  # no change, limit met
开发者ID:NamiStudio,项目名称:shuup,代码行数:26,代码来源:test_discount_codes.py


示例10: test_protected_fields

def test_protected_fields():
    activate("en")
    shop = Shop.objects.create(
        name="testshop",
        identifier="testshop",
        status=ShopStatus.ENABLED,
        public_name="test shop",
        domain="derp",
        currency="EUR"
    )
    get_currency("EUR")
    get_currency("USD")
    assert shop.name == "testshop"
    assert shop.currency == "EUR"
    assert not ConfigurationItem.objects.filter(shop=shop, key="languages").exists()
    shop_form = ShopBaseForm(instance=shop, languages=settings.LANGUAGES)
    assert not shop_form._get_protected_fields()  # No protected fields just yet, right?
    data = get_form_data(shop_form, prepared=True)
    shop_form = ShopBaseForm(data=data, instance=shop, languages=settings.LANGUAGES)
    _test_cleanliness(shop_form)
    shop_form.save()

    # Now let's make it protected!
    create_product(printable_gibberish(), shop=shop, supplier=get_default_supplier())
    order = create_random_order(customer=create_random_person(), shop=shop)
    assert order.shop == shop

    # And try again...
    data["currency"] = "USD"
    shop_form = ShopBaseForm(data=data, instance=shop, languages=settings.LANGUAGES)
    assert shop_form._get_protected_fields()  # So protected!
    _test_cleanliness(shop_form)
    shop = shop_form.save()
    assert shop.currency == "EUR"  # But the shop form ignored the change . . .
开发者ID:ruqaiya,项目名称:shuup,代码行数:34,代码来源:test_shop_edit.py


示例11: test_total_sales_customers_report

def test_total_sales_customers_report(rf):
    shop = get_default_shop()
    supplier = get_default_supplier()
    p1 = create_product("p1", shop=shop, supplier=supplier, default_price="5")
    p2 = create_product("p2", shop=shop, supplier=supplier, default_price="20")

    # orders for person 1
    person1 = create_random_person()
    order1 = create_random_order(customer=person1, completion_probability=1, products=[p1, p2])
    order2 = create_random_order(customer=person1, completion_probability=1, products=[p1, p2])

    # orders for person 2
    person2 = create_random_person()
    order3 = create_random_order(customer=person2, completion_probability=1, products=[p1, p2])
    order4 = create_random_order(customer=person2, completion_probability=1, products=[p1, p2])
    order5 = create_random_order(customer=person2, completion_probability=1, products=[p1, p2])

    # pay orders
    [o.create_payment(o.taxful_total_price) for o in Order.objects.all()]

    data = {
        "report": TotalSales.get_name(),
        "shop": shop.pk,
        "date_range": DateRangeChoices.ALL_TIME,
        "writer": "json",
        "force_download": 1,
    }
    report = TotalSales(**data)
    writer = get_writer_instance(data["writer"])
    response = writer.get_response(report=report)
    if hasattr(response, "render"):
        response.render()
    json_data = json.loads(response.content.decode("utf-8"))
    assert force_text(TotalSales.title) in json_data.get("heading")
    data = json_data.get("tables")[0].get("data")[0]

    avg_sales = (
        order1.taxful_total_price +
        order2.taxful_total_price +
        order3.taxful_total_price +
        order4.taxful_total_price +
        order5.taxful_total_price
    ) / Decimal(5)

    assert int(data["customers"]) == 2
    assert int(data["order_amount"]) == 5
    assert data["customer_avg_sale"] == str(avg_sales.value.quantize(Decimal('0.01')))
开发者ID:ruqaiya,项目名称:shuup,代码行数:47,代码来源:test_default_reports.py


示例12: get_initialized_test_event

def get_initialized_test_event():
    get_default_product()
    customer = create_random_person()
    order = create_random_order(customer)
    return ATestEvent(
        order_language=order.language,
        order=order,
        just_some_text=random_title()
    )
开发者ID:ruqaiya,项目名称:shuup,代码行数:9,代码来源:fixtures.py


示例13: test_update_order_admin_comment

def test_update_order_admin_comment(admin_user, rf):
    order = create_random_order(customer=create_random_person(), products=(get_default_product(),))
    assert order.admin_comment == ""
    view = UpdateAdminCommentView.as_view()
    comment = "updated admin comment"
    request = apply_request_middleware(rf.post("/", {"comment": comment}), user=admin_user)
    response = view(request, pk=order.pk)
    assert response.status_code < 400
    order.refresh_from_db()
    assert order.admin_comment == comment
开发者ID:ruqaiya,项目名称:shuup,代码行数:10,代码来源:test_order_module.py


示例14: test_add_order_log_entry

def test_add_order_log_entry(admin_user, rf):
    order = create_random_order(customer=create_random_person(), products=(get_default_product(),))
    assert not OrderLogEntry.objects.filter(target=order).exists()
    view = NewLogEntryView.as_view()
    test_message = "test_order"
    request = apply_request_middleware(rf.post("/", {"message": test_message}), user=admin_user)
    response = view(request, pk=order.pk)
    assert response.status_code < 400
    assert OrderLogEntry.objects.filter(target=order).exists()
    assert OrderLogEntry.objects.filter(target=order).first().message == test_message
开发者ID:ahmadzai,项目名称:shuup,代码行数:10,代码来源:test_order_module.py


示例15: test_order_set_status_completed_works

def test_order_set_status_completed_works(admin_user, rf):
    order = create_random_order(customer=create_random_person(), products=(get_default_product(),))
    order.create_shipment_of_all_products()  # Need to be shipped to set complete
    assert order.status.role == OrderStatusRole.INITIAL
    complete_status = OrderStatus.objects.get_default_complete()
    view = OrderSetStatusView.as_view()
    request = apply_request_middleware(rf.post("/", {"status": complete_status.pk}), user=admin_user)
    response = view(request, pk=order.pk)
    assert response.status_code < 400
    order = Order.objects.get(pk=order.pk)
    assert order.status_id == complete_status.id
    assert order.log_entries.filter(identifier="status_change").exists()
开发者ID:ahmadzai,项目名称:shuup,代码行数:12,代码来源:test_order_module.py


示例16: test_order_set_status_canceled_works

def test_order_set_status_canceled_works(admin_user, rf):
    order = create_random_order(customer=create_random_person(), products=(get_default_product(),))
    assert order.shipping_status == ShippingStatus.NOT_SHIPPED
    assert order.status.role == OrderStatusRole.INITIAL
    canceled_status = OrderStatus.objects.get_default_canceled()
    view = OrderSetStatusView.as_view()
    request = apply_request_middleware(rf.post("/", {"status": canceled_status.pk}), user=admin_user)
    response = view(request, pk=order.pk)
    assert response.status_code < 400
    order = Order.objects.get(pk=order.pk)
    assert order.status_id == canceled_status.id
    assert order.log_entries.filter(identifier="status_change").exists()
开发者ID:ahmadzai,项目名称:shuup,代码行数:12,代码来源:test_order_module.py


示例17: test_serialize_data

def test_serialize_data():
    """
    Test contact dashboard views
    """
    activate("en")
    shop = factories.get_default_shop()

    customer = factories.create_random_person("en")
    user = factories.create_random_user("en")
    user.set_password("1234")
    user.save()
    customer.user = user
    customer.default_billing_address = factories.create_random_address()
    customer.default_shipping_address = factories.create_random_address()
    customer.save()

    company = factories.create_random_company()
    company.default_billing_address = factories.create_random_address()
    company.default_shipping_address = factories.create_random_address()
    company.save()
    company.members.add(customer)

    product = factories.create_product("p1", shop, factories.get_default_supplier())
    for basket_customer in [customer, company]:
        [factories.create_random_order(basket_customer, [product]) for order in range(3)]

    client = SmartClient()
    client.login(username=user.username, password="1234")

    response = client.get(reverse("shuup:gdpr_customer_dashboard"))
    assert response.status_code == 200
    assert "My Data" in response.content.decode("utf-8")

    response = client.post(reverse("shuup:gdpr_download_data"))
    assert response._headers["content-disposition"][0] == "Content-Disposition"
    assert response.status_code == 200

    from shuup.tasks.models import Task, TaskType
    from shuup.gdpr.models import GDPR_ANONYMIZE_TASK_TYPE_IDENTIFIER
    response = client.post(reverse("shuup:gdpr_anonymize_account"))
    assert response.status_code == 302
    assert response.url.endswith(reverse("shuup:index"))
    task_type = TaskType.objects.get(identifier=GDPR_ANONYMIZE_TASK_TYPE_IDENTIFIER, shop=shop)
    assert Task.objects.get(type=task_type, shop=shop)

    user.refresh_from_db()
    assert user.is_active is False

    refreshed_customer = PersonContact.objects.get(id=customer.id)
    assert refreshed_customer.is_active is False
    assert refreshed_customer.name == customer.name     # nothing changed yet
开发者ID:ruqaiya,项目名称:shuup,代码行数:51,代码来源:test_front_views.py


示例18: test_recent_orders_block

def test_recent_orders_block(rf, admin_user):
    with override_settings(SHUUP_ENABLE_MULTIPLE_SHOPS=True):
        shop1 = get_default_shop()
        shop2 = get_shop(identifier="shop2", status=ShopStatus.ENABLED, name="Shop2")
        order = create_random_order(customer=create_random_person(), products=[get_default_product()])

        for shop in [shop1, shop2]:
            request = apply_request_middleware(rf.get("/"), user=admin_user, shop=shop)
            block = get_recent_orders_block(request)

            if shop == shop1:
                assert order.customer.name in block.content
            else:
                assert order.customer.name not in block.content
开发者ID:ruqaiya,项目名称:shuup,代码行数:14,代码来源:test_sales_dashboard_module.py


示例19: test_gdpr_admin_download_data

def test_gdpr_admin_download_data(client, admin_user):
    """
    Test that admin user can download customer data
    """
    activate("en")
    shop = factories.get_default_shop()
    customer = factories.create_random_person("en")
    product = factories.create_product("p1", shop, factories.get_default_supplier())
    [factories.create_random_order(customer, [product]) for order in range(3)]

    client = SmartClient()
    admin_user.set_password("admin")
    admin_user.save()
    client.login(username=admin_user.username, password="admin")
    admin_download_url = reverse("shuup_admin:gdpr.download_data", kwargs=dict(pk=customer.pk))
    response = client.post(admin_download_url)
    assert response.status_code == 200
    assert response._headers["content-disposition"][0] == "Content-Disposition"
    assert response._headers["content-disposition"][1].startswith("attachment; filename=user_data_")
开发者ID:ruqaiya,项目名称:shuup,代码行数:19,代码来源:test_admin_module.py


示例20: test_shop_api

def test_shop_api(admin_user, currency, currency_decimals):
    activate("en")
    default_shop = get_default_shop()
    client = APIClient()
    client.force_authenticate(user=admin_user)
    Currency.objects.get_or_create(code=currency, decimal_places=currency_decimals)

    shop_data = {
        "domain": "shuup.com",
        "status": ShopStatus.ENABLED.value,
        "owner": create_random_person().pk,
        "currency": currency,
        "prices_include_tax": True,
        "maintenance_mode": False,
        "translations":{
            "en": {
                "name": "Store 1",
                "public_name": "Public Store 1"
            }
        }
    }
    response = client.post("/api/shuup/shop/",
                           content_type="application/json",
                           data=json.dumps(shop_data))
    assert response.status_code == status.HTTP_201_CREATED
    shop = Shop.objects.exclude(pk=default_shop.pk).first()
    assert shop.domain == shop_data["domain"]
    assert shop.status.value == shop_data["status"]
    assert shop.owner.pk == shop_data["owner"]
    assert shop.currency == shop_data["currency"]
    assert shop.maintenance_mode == shop_data["maintenance_mode"]
    assert shop.prices_include_tax == shop_data["prices_include_tax"]
    assert shop.name == shop_data["translations"]["en"]["name"]
    assert shop.public_name == shop_data["translations"]["en"]["public_name"]

    shop_data["domain"] = "cloud.shuup.com"
    response = client.put("/api/shuup/shop/%d/" % shop.id,
                          content_type="application/json",
                          data=json.dumps(shop_data))
    assert response.status_code == status.HTTP_200_OK
    shop = Shop.objects.exclude(pk=default_shop.pk).first()
    assert shop.domain == shop_data["domain"]

    response = client.get("/api/shuup/shop/%d/" % shop.id)
    assert response.status_code == status.HTTP_200_OK
    data = json.loads(response.content.decode("utf-8"))
    assert shop.domain == data["domain"]
    assert shop.status.value == data["status"]
    assert shop.owner.pk == data["owner"]
    assert shop.currency == data["currency"]["code"]
    assert data["currency"]["symbol"] == babel.numbers.get_currency_symbol(shop.currency, get_current_babel_locale())
    assert data["currency"]["decimal_places"] == currency_decimals
    assert shop.maintenance_mode == data["maintenance_mode"]
    assert shop.prices_include_tax == data["prices_include_tax"]
    assert shop.name == data["translations"]["en"]["name"]
    assert shop.public_name == data["translations"]["en"]["public_name"]

    response = client.get("/api/shuup/shop/")
    assert response.status_code == status.HTTP_200_OK
    data = json.loads(response.content.decode("utf-8"))
    assert shop.domain == data[1]["domain"]

    response = client.delete("/api/shuup/shop/%d/" % shop.id)
    assert response.status_code == status.HTTP_204_NO_CONTENT
    assert Shop.objects.count() == 1

    # shouldn't be possible to delete a shop with a related order
    product = create_product("product1", shop=default_shop, supplier=get_default_supplier())
    create_random_order(create_random_person(), [product], completion_probability=1, shop=default_shop)
    response = client.delete("/api/shuup/shop/%d/" % default_shop.id)
    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert "This object can not be deleted because it is referenced by" in response.content.decode("utf-8")
    assert Shop.objects.count() == 1
开发者ID:ruqaiya,项目名称:shuup,代码行数:73,代码来源:test_shop_api.py



注:本文中的shuup.testing.factories.create_random_order函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.create_random_person函数代码示例发布时间:2022-05-27
下一篇:
Python factories.create_product函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap