Added product tests

This commit is contained in:
2024-01-10 23:44:59 +00:00
parent babc1d6471
commit 75e7ad5994
5 changed files with 67 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ from .database import DatabaseController
from models.products.product import Product
class ProductController(DatabaseController):
FIELDS = ['id', 'name', 'image', 'description', 'cost', 'category', 'sellerID', 'postedDate', 'quantity']
FIELDS = ['id', 'name', 'image', 'description', 'cost', 'category', 'sellerID', 'postedDate', 'quantityAvailable']
def __init__(self):
super().__init__()
@@ -20,7 +20,7 @@ class ProductController(DatabaseController):
]
self._conn.execute(
"INSERT INTO Products (name, cost, image, description, category, sellerID, postedDate, quantityAvailable) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
"INSERT INTO Products (name, image, description, cost, categoryID, sellerID, postedDate, quantityAvailable) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
params
)
self._conn.commit()
@@ -46,7 +46,7 @@ class ProductController(DatabaseController):
for product in rows:
params = dict(zip(self.FIELDS, product))
obj = self.new_instance(Product, params)
products.push(obj)
products.append(obj)
return products