Fix empty category handling
This commit is contained in:
@@ -6,7 +6,7 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
||||
|
||||
import pytest
|
||||
|
||||
from sigl.domain.service import product_by_id, product_create
|
||||
from sigl.domain.service import product_by_id, product_create, products_all
|
||||
|
||||
# Always use 'app' fixture so ORM gets initialized
|
||||
pytestmark = pytest.mark.usefixtures('app')
|
||||
@@ -24,6 +24,18 @@ def test_product_create_defaults(session):
|
||||
assert not p.locations
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_product_create_without_category(session):
|
||||
"""Test that a Product can be created with a blank Category."""
|
||||
pc = product_create(session, 'Eggs')
|
||||
|
||||
assert pc.id is not None
|
||||
assert pc.name == 'Eggs'
|
||||
assert pc.category == ''
|
||||
assert pc.remember is True
|
||||
assert not pc.locations
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_product_create_forget(session):
|
||||
"""Test newly created Products can have remember as false."""
|
||||
@@ -34,3 +46,17 @@ def test_product_create_forget(session):
|
||||
assert p.category == 'Dairy'
|
||||
assert p.remember is False
|
||||
assert not p.locations
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_product_all_items_skips_non_remembered(session):
|
||||
"""Test that querying all Product items skips non-remembered Products."""
|
||||
p1 = product_create(session, 'Apples')
|
||||
p2 = product_create(session, 'Bananas', remember=False)
|
||||
p3 = product_create(session, 'Carrots')
|
||||
|
||||
products = products_all(session)
|
||||
assert len(products) == 2
|
||||
assert p1 in products
|
||||
assert p3 in products
|
||||
assert p2 not in products
|
||||
|
||||
Reference in New Issue
Block a user