From d69f35cfcc35f7802593727ffed41a656eae01bc Mon Sep 17 00:00:00 2001 From: polyfloyd Date: Mon, 21 Apr 2025 11:14:17 +0200 Subject: [PATCH] Move revbank test asserts to a test file --- inflatinator/revbank.py | 10 ---------- inflatinator/revbank_test.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 inflatinator/revbank_test.py diff --git a/inflatinator/revbank.py b/inflatinator/revbank.py index d140939..f5aeb50 100644 --- a/inflatinator/revbank.py +++ b/inflatinator/revbank.py @@ -50,16 +50,6 @@ class Product: return f'{aliases:<30} {price:<6} {description:<60} {metadata}' -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}) -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' - - class NoAutoUpdate(Exception): def __init__(self): super().__init__('no auto update directive') diff --git a/inflatinator/revbank_test.py b/inflatinator/revbank_test.py new file mode 100644 index 0000000..96db8cb --- /dev/null +++ b/inflatinator/revbank_test.py @@ -0,0 +1,16 @@ +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'