Passed
Push — main ( 52c0ea...0cab68 )
by Jochen
04:36
created

make_article()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2022 Jochen Kupperschmidt
3
:License: Revised BSD (see `LICENSE` file for details)
4
"""
5
6
import pytest
7
8
from byceps.services.brand.transfer.models import Brand
9
from byceps.services.shop.article.transfer.models import Article
10
from byceps.services.shop.cart.models import Cart
11
from byceps.services.shop.order.transfer.order import Orderer
12
from byceps.services.shop.shop.transfer.models import Shop, ShopID
13
from byceps.services.shop.storefront.transfer.models import Storefront
14
from byceps.services.snippet import service as snippet_service
15
from byceps.services.snippet.transfer.models import Scope, SnippetID
16
from byceps.services.user.transfer.models import User
17
from byceps.typing import UserID
18
19
from .helpers import create_article, create_orderer
20
21
22
@pytest.fixture
23
def shop_brand(make_brand, make_email_config) -> Brand:
24
    brand = make_brand()
25
26
    email_config = make_email_config(
27
        brand.id, sender_address='[email protected]'
28
    )
29
30
    return brand
31
32
33
@pytest.fixture
34
def email_footer_snippet_id(shop_brand: Brand, admin_user: User) -> SnippetID:
35
    scope = Scope.for_brand(shop_brand.id)
36
37
    version, _ = snippet_service.create_fragment(
38
        scope,
39
        'email_footer',
40
        admin_user.id,
41
        '''
42
Für Fragen stehen wir gerne zur Verfügung.
43
44
Viele Grüße,
45
das Team der Acme Entertainment Convention
46
47
-- 
48
Acme Entertainment Convention
49
50
E-Mail: [email protected]
51
''',
52
    )
53
54
    return version.snippet_id
55
56
57
@pytest.fixture
58
def shop(shop_brand: Brand, make_email_config, make_shop) -> Shop:
59
    return make_shop(shop_brand.id)
60
61
62
@pytest.fixture
63
def storefront(
64
    shop: Shop, make_order_number_sequence, make_storefront
65
) -> Storefront:
66
    order_number_sequence = make_order_number_sequence(shop.id)
67
68
    return make_storefront(shop.id, order_number_sequence.id)
69
70
71
@pytest.fixture(scope='session')
72
def make_article():
73
    def _wrapper(shop_id: ShopID, **kwargs) -> Article:
74
        return create_article(shop_id, **kwargs)
75
76
    return _wrapper
77
78
79
@pytest.fixture(scope='session')
80
def make_orderer():
81
    def _wrapper(user_id: UserID) -> Orderer:
82
        return create_orderer(user_id)
83
84
    return _wrapper
85
86
87
@pytest.fixture
88
def empty_cart() -> Cart:
89
    return Cart()
90