From 59c9bb2e7142cf6fafd717a2ea102b0f25de671c Mon Sep 17 00:00:00 2001 From: s3lph Date: Wed, 11 Dec 2024 00:21:00 +0100 Subject: [PATCH] fix: barcodes unittest --- matemat/db/facade.py | 2 +- matemat/db/test/test_facade.py | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/matemat/db/facade.py b/matemat/db/facade.py index 882051e..d48051a 100644 --- a/matemat/db/facade.py +++ b/matemat/db/facade.py @@ -553,7 +553,7 @@ class MatematDatabase(object): price_non_member = :price_non_member, custom_price = :custom_price, stock = :stock, - stockable = :stockable, + stockable = :stockable WHERE product_id = :product_id ''', { 'product_id': product.id, diff --git a/matemat/db/test/test_facade.py b/matemat/db/test/test_facade.py index 7aba835..70fb79e 100644 --- a/matemat/db/test/test_facade.py +++ b/matemat/db/test/test_facade.py @@ -229,7 +229,6 @@ class DatabaseTest(unittest.TestCase): self.assertEqual(200, row[4]) self.assertEqual(200, row[5]) self.assertEqual(1, row[6]) - self.assertEqual('4029764001807', row[7]) with self.assertRaises(ValueError): db.create_product('Club Mate', 250, 250, False, False, '4029764001807') @@ -242,7 +241,6 @@ class DatabaseTest(unittest.TestCase): self.assertEqual(150, product.price_member) self.assertEqual(250, product.price_non_member) self.assertEqual(False, product.stockable) - self.assertEqual('4029764001807', product.ean) with self.assertRaises(ValueError): db.get_product(-1) @@ -262,25 +260,24 @@ class DatabaseTest(unittest.TestCase): self.assertEqual(200, product.price_member) self.assertEqual(200, product.price_non_member) self.assertTrue(product.stockable) - self.assertEqual('4029764001807', product.ean) elif product.name == 'Flora Power Mate': self.assertEqual(200, product.price_member) self.assertEqual(200, product.price_non_member) self.assertFalse(product.stockable) - self.assertEqual(None, product.ean) elif product.name == 'Fritz Mate': self.assertEqual(200, product.price_member) self.assertEqual(250, product.price_non_member) self.assertTrue(product.stockable) - self.assertEqual('4260107223177', product.ean) productcheck[product.id] = 1 self.assertEqual(3, len(productcheck)) def test_change_product(self) -> None: with self.db as db: product = db.create_product('Club Mate', 200, 200, False, True, '4029764001807') + barcodes = db.list_barcodes(product.id) db.change_product(product, name='Flora Power Mate', price_member=150, price_non_member=250, - custom_price=True, stock=None, stockable=False, ean=None) + custom_price=True, stock=None, stockable=False) + db.delete_barcode(barcodes[0]) # Changes must be reflected in the passed object self.assertEqual('Flora Power Mate', product.name) self.assertEqual(150, product.price_member) @@ -288,7 +285,8 @@ class DatabaseTest(unittest.TestCase): self.assertEqual(True, product.custom_price) self.assertEqual(None, product.stock) self.assertEqual(False, product.stockable) - self.assertEqual(None, product.ean) + self.assertEqual(1, len(barcodes)) + self.assertEqual('4029764001807', barcodes[0].barcode) # Changes must be reflected in the database checkproduct = db.get_product(product.id) self.assertEqual('Flora Power Mate', checkproduct.name)