1 | """ |
||
2 | :Copyright: 2006-2021 Jochen Kupperschmidt |
||
3 | :License: Revised BSD (see `LICENSE` file for details) |
||
4 | """ |
||
5 | |||
6 | from byceps.services.authentication.session.models.current_user import ( |
||
7 | CurrentUser, |
||
8 | ) |
||
9 | from byceps.services.authentication.session import service as session_service |
||
10 | from byceps.services.shop.cart.models import Cart |
||
11 | from byceps.services.shop.order import service as order_service |
||
12 | |||
13 | from tests.integration.services.shop.helpers import create_orderer |
||
14 | |||
15 | |||
16 | def get_current_user_for_user(user) -> CurrentUser: |
||
17 | return session_service.get_authenticated_current_user( |
||
18 | user, locale=None, permissions=frozenset() |
||
19 | ) |
||
20 | |||
21 | |||
22 | def place_order_with_items( |
||
23 | storefront_id, user, created_at=None, items_with_quantity=None |
||
24 | ): |
||
25 | orderer = create_orderer(user.id) |
||
26 | |||
27 | cart = Cart() |
||
28 | |||
29 | if items_with_quantity is not None: |
||
30 | for article, quantity in items_with_quantity: |
||
31 | cart.add_item(article, quantity) |
||
32 | |||
33 | order, _ = order_service.place_order( |
||
34 | storefront_id, orderer, cart, created_at=created_at |
||
35 | ) |
||
36 | |||
37 | return order |
||
38 | |||
39 | |||
40 | View Code Duplication | def assert_email( |
|
1 ignored issue
–
show
Duplication
introduced
by
Loading history...
|
|||
41 | mock, expected_sender, expected_recipients, expected_subject, expected_body |
||
42 | ): |
||
43 | calls = mock.call_args_list |
||
44 | assert len(calls) == 1 |
||
45 | |||
46 | args = calls[0].args |
||
47 | assert args[0] == expected_sender |
||
48 | assert args[1] == expected_recipients |
||
49 | assert args[2] == expected_subject |
||
50 | assert args[3] == expected_body |
||
51 |