20 lines
1.5 KiB
Python
20 lines
1.5 KiB
Python
from revbank import Product
|
|
from decimal import Decimal
|
|
|
|
|
|
def test_parse_product_lines():
|
|
assert Product.from_line('8711327538481,liuk 0.80 "Ola Liuk" #ah=wi162664 #qty=8') == \
|
|
Product(['8711327538481','liuk'], Decimal('0.8'), 'Ola Liuk', {'ah': 'wi162664', 'qty': '8'})
|
|
assert Product.from_line('5000112659184,colazero 1.00 "Cola Zero" #sligro') == \
|
|
Product(['5000112659184','colazero'], Decimal(1), 'Cola Zero', {'sligro': None})
|
|
|
|
|
|
def test_format_product_lines():
|
|
assert Product.from_line('8711327538481,liuk 0.80 "Ola Liuk" #ah=wi162664 #qty=8').format_line() == \
|
|
'8711327538481,liuk 0.80 "Ola Liuk" #ah=wi162664 #qty=8'
|
|
assert Product(['5000112659184','colazero'], Decimal(1), 'Cola Zero', {'sligro': None}).format_line() == \
|
|
'5000112659184,colazero 1.00 "Cola Zero" #sligro'
|
|
assert Product(['8711327607569','8712566340309','magnumwhite'], Decimal(1.50), 'Magnum White chocolate', {'ah': None}).format_line() == \
|
|
'8711327607569,8712566340309,magnumwhite 1.50 "Magnum White chocolate" #ah'
|
|
assert Product(['8717677337712','8717677336036','8717677337729'], Decimal(1.95), 'Tony\'s Chocolonely Chocoladereep melk met karamel en zeezout, FT (47 gram)', {'sligro': None}).format_line() == \
|
|
'8717677337712,8717677336036,8717677337729 1.95 "Tony\'s Chocolonely Chocoladereep melk met karamel en zeezout, FT (47 gram)" #sligro'
|