Passed
Push — main ( 309543...6dfe4e )
by Jochen
04:25
created

integration/services/shop/order/email/helpers.py (1 issue)

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
This code seems to be duplicated in your project.
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
    pos_args, _ = calls[0]
47
    actual_sender, actual_recipients, actual_subject, actual_body = pos_args
48
    assert actual_sender == expected_sender
49
    assert actual_recipients == expected_recipients
50
    assert actual_subject == expected_subject
51
    assert actual_body == expected_body
52