fix: barcodes unittest
This commit is contained in:
parent
e23ba65c71
commit
59c9bb2e71
2 changed files with 6 additions and 8 deletions
|
@ -553,7 +553,7 @@ class MatematDatabase(object):
|
||||||
price_non_member = :price_non_member,
|
price_non_member = :price_non_member,
|
||||||
custom_price = :custom_price,
|
custom_price = :custom_price,
|
||||||
stock = :stock,
|
stock = :stock,
|
||||||
stockable = :stockable,
|
stockable = :stockable
|
||||||
WHERE product_id = :product_id
|
WHERE product_id = :product_id
|
||||||
''', {
|
''', {
|
||||||
'product_id': product.id,
|
'product_id': product.id,
|
||||||
|
|
|
@ -229,7 +229,6 @@ class DatabaseTest(unittest.TestCase):
|
||||||
self.assertEqual(200, row[4])
|
self.assertEqual(200, row[4])
|
||||||
self.assertEqual(200, row[5])
|
self.assertEqual(200, row[5])
|
||||||
self.assertEqual(1, row[6])
|
self.assertEqual(1, row[6])
|
||||||
self.assertEqual('4029764001807', row[7])
|
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
db.create_product('Club Mate', 250, 250, False, False, '4029764001807')
|
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(150, product.price_member)
|
||||||
self.assertEqual(250, product.price_non_member)
|
self.assertEqual(250, product.price_non_member)
|
||||||
self.assertEqual(False, product.stockable)
|
self.assertEqual(False, product.stockable)
|
||||||
self.assertEqual('4029764001807', product.ean)
|
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
db.get_product(-1)
|
db.get_product(-1)
|
||||||
|
|
||||||
|
@ -262,25 +260,24 @@ class DatabaseTest(unittest.TestCase):
|
||||||
self.assertEqual(200, product.price_member)
|
self.assertEqual(200, product.price_member)
|
||||||
self.assertEqual(200, product.price_non_member)
|
self.assertEqual(200, product.price_non_member)
|
||||||
self.assertTrue(product.stockable)
|
self.assertTrue(product.stockable)
|
||||||
self.assertEqual('4029764001807', product.ean)
|
|
||||||
elif product.name == 'Flora Power Mate':
|
elif product.name == 'Flora Power Mate':
|
||||||
self.assertEqual(200, product.price_member)
|
self.assertEqual(200, product.price_member)
|
||||||
self.assertEqual(200, product.price_non_member)
|
self.assertEqual(200, product.price_non_member)
|
||||||
self.assertFalse(product.stockable)
|
self.assertFalse(product.stockable)
|
||||||
self.assertEqual(None, product.ean)
|
|
||||||
elif product.name == 'Fritz Mate':
|
elif product.name == 'Fritz Mate':
|
||||||
self.assertEqual(200, product.price_member)
|
self.assertEqual(200, product.price_member)
|
||||||
self.assertEqual(250, product.price_non_member)
|
self.assertEqual(250, product.price_non_member)
|
||||||
self.assertTrue(product.stockable)
|
self.assertTrue(product.stockable)
|
||||||
self.assertEqual('4260107223177', product.ean)
|
|
||||||
productcheck[product.id] = 1
|
productcheck[product.id] = 1
|
||||||
self.assertEqual(3, len(productcheck))
|
self.assertEqual(3, len(productcheck))
|
||||||
|
|
||||||
def test_change_product(self) -> None:
|
def test_change_product(self) -> None:
|
||||||
with self.db as db:
|
with self.db as db:
|
||||||
product = db.create_product('Club Mate', 200, 200, False, True, '4029764001807')
|
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,
|
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
|
# Changes must be reflected in the passed object
|
||||||
self.assertEqual('Flora Power Mate', product.name)
|
self.assertEqual('Flora Power Mate', product.name)
|
||||||
self.assertEqual(150, product.price_member)
|
self.assertEqual(150, product.price_member)
|
||||||
|
@ -288,7 +285,8 @@ class DatabaseTest(unittest.TestCase):
|
||||||
self.assertEqual(True, product.custom_price)
|
self.assertEqual(True, product.custom_price)
|
||||||
self.assertEqual(None, product.stock)
|
self.assertEqual(None, product.stock)
|
||||||
self.assertEqual(False, product.stockable)
|
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
|
# Changes must be reflected in the database
|
||||||
checkproduct = db.get_product(product.id)
|
checkproduct = db.get_product(product.id)
|
||||||
self.assertEqual('Flora Power Mate', checkproduct.name)
|
self.assertEqual('Flora Power Mate', checkproduct.name)
|
||||||
|
|
Loading…
Reference in a new issue