Total Complexity | 3 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |