~homeworkprod/byceps

ref: 43bf3630475839afde6e691f0ac561dcb01aaba6 byceps/testfixtures/shop_article.py -rw-r--r-- 933 bytes
43bf3630 — Jochen Kupperschmidt Upgrade pytest on Travis CI to get v3.3 rather than v3.0 provided by default 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
testfixtures.shop_article
~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from decimal import Decimal

from byceps.services.shop.article.models.article import Article

from .party import create_party


ANY_ARTICLE_ITEM_NUMBER = 'AEC-05-A00009'


def create_article(*, party_id=None, item_number=ANY_ARTICLE_ITEM_NUMBER,
                   description='Cool thing', price=None, tax_rate=None,
                   available_from=None, available_until=None, quantity=1):
    if party_id is None:
        party = create_party()
        party_id = party.id

    if price is None:
        price = Decimal('24.95')

    if tax_rate is None:
        tax_rate = Decimal('0.19')

    return Article(party_id, item_number, description, price, tax_rate,
                   quantity, available_from=available_from,
                   available_until=available_until)