當前位置: 首頁>>代碼示例>>Python>>正文


Python core.Checkout類代碼示例

本文整理匯總了Python中saleor.checkout.core.Checkout的典型用法代碼示例。如果您正苦於以下問題:Python Checkout類的具體用法?Python Checkout怎麽用?Python Checkout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Checkout類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_checkout_shipping_method

def test_checkout_shipping_method(shipping_address, shipping_method, value, monkeypatch):
    queryset = Mock(get=Mock(return_value=shipping_method))
    monkeypatch.setattr(Checkout, 'shipping_address', shipping_address)
    monkeypatch.setattr('saleor.checkout.core.ShippingMethodCountry.objects', queryset)
    checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
    checkout.storage['shipping_method_country_id'] = 1
    assert checkout.shipping_method == value
開發者ID:fnugrahendi,項目名稱:saleor,代碼行數:7,代碼來源:test_checkout.py

示例2: test_checkout_shipping_method_setter

def test_checkout_shipping_method_setter():
    shipping_method = Mock(id=1)
    checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
    assert checkout.modified is False
    checkout.shipping_method = shipping_method
    assert checkout.modified is True
    assert checkout.storage['shipping_method_country_id'] == 1
開發者ID:fnugrahendi,項目名稱:saleor,代碼行數:7,代碼來源:test_checkout.py

示例3: test_checkout_shipping_does_not_exists

def test_checkout_shipping_does_not_exists(monkeypatch):
    queryset = Mock(get=Mock(side_effect=ShippingMethodCountry.DoesNotExist))
    monkeypatch.setattr(
        'saleor.checkout.core.ShippingMethodCountry.objects', queryset)
    checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
    checkout.storage['shipping_method_country_id'] = 1
    assert checkout.shipping_method is None
開發者ID:patrys,項目名稱:saleor,代碼行數:7,代碼來源:test_checkout.py

示例4: test_checkout_shipping_address_with_storage

def test_checkout_shipping_address_with_storage(
        address_objects, shipping, monkeypatch):
    monkeypatch.setattr(
        'saleor.checkout.core.Address.objects', address_objects)
    checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
    checkout.storage['shipping_address'] = {'id': 1}
    assert checkout.shipping_address == shipping
開發者ID:patrys,項目名稱:saleor,代碼行數:7,代碼來源:test_checkout.py

示例5: test_checkout_shipping_address_setter

def test_checkout_shipping_address_setter():
    address = Address(first_name='Jan', last_name='Kowalski')
    checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
    checkout.shipping_address = address
    assert checkout.storage['shipping_address'] == {
        'city': u'', 'city_area': u'', 'company_name': u'', 'country': '', 'phone': u'',
        'country_area': u'', 'first_name': 'Jan', 'id': None, 'last_name': 'Kowalski',
        'postal_code': u'', 'street_address_1': u'', 'street_address_2': u''}
開發者ID:fnugrahendi,項目名稱:saleor,代碼行數:8,代碼來源:test_checkout.py

示例6: test_index_view

def test_index_view(cart, status_code, url, rf):
    checkout = Checkout(cart, AnonymousUser(), 'tracking_code')
    request = rf.get('checkout:index')
    request.user = checkout.user
    request.session = {STORAGE_SESSION_KEY: checkout.for_storage()}
    request.discounts = []
    response = views.index_view(request, checkout, checkout.cart)
    assert response.status_code == status_code
    assert response.url == url
開發者ID:fnugrahendi,項目名稱:saleor,代碼行數:9,代碼來源:test_checkout.py

示例7: test_note_in_created_order

def test_note_in_created_order(request_cart, customer_user, billing_address):
    customer_user.default_billing_address = billing_address
    checkout = Checkout(request_cart, customer_user, 'tracking_code')
    checkout.note = ''
    order = checkout.create_order()
    assert not order.notes.all()
    checkout.note = 'test_note'
    order = checkout.create_order()
    assert order.notes.values()[0].get('content') == 'test_note'
開發者ID:patrys,項目名稱:saleor,代碼行數:9,代碼來源:test_checkout.py

示例8: test_checkout_create_order_insufficient_stock

def test_checkout_create_order_insufficient_stock(
        request_cart, customer_user, product):
    product_type = product.product_type
    product_type.is_shipping_required = False
    product_type.save()
    variant = product.variants.get()
    request_cart.add(variant, quantity=10, check_quantity=False)
    checkout = Checkout(request_cart, customer_user, 'tracking_code')
    with pytest.raises(InsufficientStock):
        checkout.create_order()
開發者ID:zdobooto,項目名稱:saleor,代碼行數:10,代碼來源:test_checkout.py

示例9: test_index_view

def test_index_view(cart, status_code, url, rf, monkeypatch):
    checkout = Checkout(cart, AnonymousUser(), 'tracking_code')
    request = rf.get('checkout:index')
    request.user = checkout.user
    request.session = {STORAGE_SESSION_KEY: checkout.for_storage()}
    request.discounts = []
    monkeypatch.setattr(
        'saleor.cart.utils.get_cart_from_request', lambda req, qs: cart)
    response = views.index_view(request)
    assert response.status_code == status_code
    assert response.url == url
開發者ID:patrys,項目名稱:saleor,代碼行數:11,代碼來源:test_checkout.py

示例10: test_checkout_clear_storage

def test_checkout_clear_storage():
    checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
    checkout.storage['new'] = 1
    checkout.clear_storage()
    assert checkout.storage is None
    assert checkout.modified is True
開發者ID:fnugrahendi,項目名稱:saleor,代碼行數:6,代碼來源:test_checkout.py

示例11: test_checkout_version_with_from_storage

def test_checkout_version_with_from_storage(storage_data, expected_storage):
    checkout = Checkout.from_storage(
        storage_data, Mock(), AnonymousUser(), 'tracking_code')
    storage = checkout.for_storage()
    assert storage == expected_storage
開發者ID:fnugrahendi,項目名稱:saleor,代碼行數:5,代碼來源:test_checkout.py

示例12: test_checkout_version

def test_checkout_version():
    checkout = Checkout(Mock(), AnonymousUser(), 'tracking_code')
    storage = checkout.for_storage()
    assert storage['version'] == Checkout.VERSION
開發者ID:fnugrahendi,項目名稱:saleor,代碼行數:4,代碼來源:test_checkout.py

示例13: test_checkout_discount

def test_checkout_discount(request_cart, sale, product_in_stock):
    variant = product_in_stock.variants.get()
    request_cart.add(variant, 1)
    checkout = Checkout(request_cart, AnonymousUser(), 'tracking_code')
    assert checkout.get_total() == Price(currency="USD", net=5)
開發者ID:patrys,項目名稱:saleor,代碼行數:5,代碼來源:test_checkout.py

示例14: test_checkout_discount

def test_checkout_discount(request_cart, sale, product_in_stock):
    variant = product_in_stock.variants.get()
    request_cart.add(variant, 1)
    checkout = Checkout(request_cart, AnonymousUser(), 'tracking_code')
    assert checkout.get_total() == TaxedMoney(
        net=Money(5, 'USD'), gross=Money(5, 'USD'))
開發者ID:artursmet,項目名稱:saleor,代碼行數:6,代碼來源:test_checkout.py


注:本文中的saleor.checkout.core.Checkout類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。