Products can now be searched using search term
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user