Completed
Push — main ( cd54d0...3ec8de )
by Jochen
03:28
created

tests.integration.services.shop.order.email.helpers   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A place_order_with_items() 0 16 3
1
"""
2
:Copyright: 2006-2020 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE for details.
4
"""
5
6
from byceps.services.shop.cart.models import Cart
7
from byceps.services.shop.order import service as order_service
8
9
from testfixtures.shop_order import create_orderer
10
11
12
def place_order_with_items(
13
    storefront_id, user, created_at=None, items_with_quantity=None
14
):
15
    orderer = create_orderer(user)
16
17
    cart = Cart()
18
19
    if items_with_quantity is not None:
20
        for article, quantity in items_with_quantity:
21
            cart.add_item(article, quantity)
22
23
    order, _ = order_service.place_order(
24
        storefront_id, orderer, cart, created_at=created_at
25
    )
26
27
    return order
28