Test Failed
Push — main ( e3918a...309543 )
by Jochen
04:24
created

make_order_number_sequence_id()   A

Complexity

Conditions 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 1
dl 0
loc 13
rs 9.95
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2021 Jochen Kupperschmidt
3
:License: Revised BSD (see `LICENSE` file for details)
4
"""
5
6
import pytest
7
8
from byceps.services.shop.order import (
9
    sequence_service as order_sequence_service,
10
)
11
from byceps.services.shop.order.transfer.models import OrderNumberSequenceID
12
from byceps.services.shop.shop.transfer.models import Shop
13
from byceps.services.shop.storefront import service as storefront_service
14
from byceps.services.shop.storefront.transfer.models import (
15
    Storefront,
16
    StorefrontID,
17
)
18
from byceps.services.snippet.transfer.models import SnippetID
19
from byceps.services.user.transfer.models import User
20
21
from tests.integration.services.shop.helpers import create_shop_fragment
22
23
24
pytest.register_assert_rewrite(f'{__package__}.helpers')
25
26
27
@pytest.fixture(scope='package')
28
def order_admin(make_user):
29
    return make_user()
30
31
32
@pytest.fixture
33
def make_order_number_sequence_id(shop: Shop):
34
    def _wrapper(value: int) -> OrderNumberSequenceID:
35
        sequence_id = order_sequence_service.create_order_number_sequence(
36
            shop.id, 'AC-14-B', value=value
37
        )
38
39
        if sequence_id is None:
40
            raise Exception('Got no order number sequence ID')
41
42
        return sequence_id
43
44
    return _wrapper
45
46
47
@pytest.fixture
48
def make_storefront(shop: Shop):
49
    def _wrapper(order_number_sequence_id: OrderNumberSequenceID) -> Storefront:
50
        return storefront_service.create_storefront(
51
            StorefrontID(f'{shop.id}-storefront'),
52
            shop.id,
53
            order_number_sequence_id,
54
            closed=False,
55
        )
56
57
    return _wrapper
58
59
60
@pytest.fixture
61
def email_footer_snippet_id(shop: Shop, order_admin: User) -> SnippetID:
62
    return create_shop_fragment(
63
        shop.id,
64
        order_admin.id,
65
        'email_footer',
66
        '''
67
Für Fragen stehen wir gerne zur Verfügung.
68
69
Viele Grüße,
70
das Team der Acme Entertainment Convention
71
72
-- 
73
Acme Entertainment Convention
74
75
E-Mail: [email protected]
76
''',
77
    )
78
79
80
@pytest.fixture
81
def email_payment_instructions_snippet_id(
82
    shop: Shop, order_admin: User
83
) -> SnippetID:
84
    return create_shop_fragment(
85
        shop.id,
86
        order_admin.id,
87
        'email_payment_instructions',
88
        '''
89
Bitte überweise den Gesamtbetrag auf folgendes Konto:
90
91
  Zahlungsempfänger: <Name>
92
  IBAN: <IBAN>
93
  BIC: <BIC>
94
  Bank: <Kreditinstitut>
95
  Verwendungszweck: {{ order_number }}
96
97
Wir werden dich informieren, sobald wir deine Zahlung erhalten haben.
98
99
Hier kannst du deine Bestellungen einsehen: https://www.acmecon.test/shop/orders
100
''',
101
    )
102