Products can now be searched using search term

This commit is contained in:
2024-01-15 21:47:18 +00:00
parent 40d7469321
commit 36a04d58e1
4 changed files with 36 additions and 7 deletions

View File

@ -27,6 +27,26 @@ def test_duplicate_product():
with pytest.raises(sqlite3.IntegrityError):
db.create(product)
# Tests that products can be refined by category
def test_search_category():
db = ProductController()
# Check each category for correct amount of test products
assert len(db.read_all("Car Parts")) == 9 + 1 # Added in previous test
assert len(db.read_all("Books")) == 9
assert db.read_all("Phones") == None
# Tests that products can be refined by search term
def test_search_term():
db = ProductController()
# Check each search term for correct amount of test products
assert len(db.read_all(search_term="test")) == 33
assert len(db.read_all("Car Parts", "test")) == 9
assert len(db.read_all(search_term="product")) == 1
assert db.read_all(search_term="not_test") == None
# Test we the same product details get returned from the database
def test_read_product():
db = ProductController()