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'