Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JakNowy committed Jun 9, 2024
1 parent a49bfe5 commit e4cb0ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 7 additions & 5 deletions tests/sqlalchemy/core/test_parse_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ async def test_parse_filters_not_contained_in(test_model):


@pytest.mark.asyncio
@pytest.mark.parametrize("type", ("in", "not_in"))
async def test_parse_filters_contained_in_raises_exception(test_model, type: str):
@pytest.mark.parametrize("operator", ("in", "not_in", "between"))
async def test_parse_filters_raises_exception(test_model, operator: str):
fast_crud = FastCRUD(test_model)
with pytest.raises(ValueError) as exc:
if type == "in":
if operator == "in":
fast_crud._parse_filters(category_id__in=1)
elif type == "not_in":
elif operator == "not_in":
fast_crud._parse_filters(category_id__not_in=1)
assert str(exc.value) == "in filter must be tuple, list or set"
elif operator == "between":
fast_crud._parse_filters(category_id__between=1)
assert str(exc.value) == f"<{operator}> filter must be tuple, list or set"


@pytest.mark.asyncio
Expand Down
12 changes: 9 additions & 3 deletions tests/sqlmodel/core/test_parse_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ async def test_parse_filters_contained_in(test_model):


@pytest.mark.asyncio
async def test_parse_filters_contained_in_exception(test_model):
@pytest.mark.parametrize("operator", ("in", "not_in", "between"))
async def test_parse_filters_raises_exception(test_model, operator: str):
fast_crud = FastCRUD(test_model)
with pytest.raises(ValueError) as exc:
fast_crud._parse_filters(category_id__in=1)
assert str(exc.value) == "in filter must be tuple, list or set"
if operator == "in":
fast_crud._parse_filters(category_id__in=1)
elif operator == "not_in":
fast_crud._parse_filters(category_id__not_in=1)
elif operator == "between":
fast_crud._parse_filters(category_id__between=1)
assert str(exc.value) == f"<{operator}> filter must be tuple, list or set"


@pytest.mark.asyncio
Expand Down

0 comments on commit e4cb0ee

Please sign in to comment.