Completed
Push — main ( b7acb4...84e7fd )
by Jochen
03:57
created

test_generate_order_number_default()   A

Complexity

Conditions 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nop 2
dl 0
loc 15
rs 9.95
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2020 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE 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.shop import service as shop_service
12
13
14
@pytest.fixture(scope='module')
15
def shop1(email_config):
16
    shop = shop_service.create_shop('shop-01', 'Some Shop', email_config.id)
17
    yield shop
18
    shop_service.delete_shop(shop.id)
19
20
21
@pytest.fixture(scope='module')
22
def shop2(email_config):
23
    shop = shop_service.create_shop('shop-02', 'Another Shop', email_config.id)
24
    yield shop
25
    shop_service.delete_shop(shop.id)
26
27
28
def test_generate_order_number_default(admin_app, shop1):
29
    shop = shop1
30
31
    order_number_sequence_id = (
32
        order_sequence_service.create_order_number_sequence(shop.id, 'AEC-01-B')
33
    )
34
35
    actual = order_sequence_service.generate_order_number(
36
        order_number_sequence_id
37
    )
38
39
    assert actual == 'AEC-01-B00001'
40
41
    order_sequence_service.delete_order_number_sequence(
42
        order_number_sequence_id
43
    )
44
45
46
def test_generate_order_number_custom(admin_app, shop2):
47
    shop = shop2
48
49
    last_assigned_order_sequence_number = 206
50
51
    order_number_sequence_id = (
52
        order_sequence_service.create_order_number_sequence(
53
            shop.id, 'LOL-03-B', value=last_assigned_order_sequence_number
54
        )
55
    )
56
57
    actual = order_sequence_service.generate_order_number(
58
        order_number_sequence_id
59
    )
60
61
    assert actual == 'LOL-03-B00207'
62
63
    order_sequence_service.delete_order_number_sequence(
64
        order_number_sequence_id
65
    )
66