diff --git a/tests/test_get.py b/tests/test_get.py index ae5ffdf..63c4a2e 100644 --- a/tests/test_get.py +++ b/tests/test_get.py @@ -29,24 +29,3 @@ def test_get_not_found(argument, expected_msg, fresh_db): fresh_db["dogs"].get(argument) if expected_msg is not None: assert expected_msg == excinfo.value.args[0] - - -@pytest.mark.parametrize( - "where,where_args,expected_ids", - [ - ("name = ?", ["Pancakes"], {2}), - ("age > ?", [3], {1}), - ("name is not null", [], {1, 2}), - ("is_good = ?", [True], {1, 2}), - ], -) -def test_rows_where(where, where_args, expected_ids, fresh_db): - table = fresh_db["dogs"] - table.insert_all( - [ - {"id": 1, "name": "Cleo", "age": 4, "is_good": True}, - {"id": 2, "name": "Pancakes", "age": 3, "is_good": True}, - ], - pk="id", - ) - assert expected_ids == {r["id"] for r in table.rows_where(where, where_args)} diff --git a/tests/test_introspect.py b/tests/test_introspect.py index 7c01a0b..bebe537 100644 --- a/tests/test_introspect.py +++ b/tests/test_introspect.py @@ -62,12 +62,6 @@ def test_columns(existing_db): ] -def test_rows(existing_db): - assert [{"text": "one"}, {"text": "two"}, {"text": "three"}] == list( - existing_db["foo"].rows - ) - - def test_schema(existing_db): assert "CREATE TABLE foo (text TEXT)" == existing_db["foo"].schema diff --git a/tests/test_rows.py b/tests/test_rows.py new file mode 100644 index 0000000..115f26a --- /dev/null +++ b/tests/test_rows.py @@ -0,0 +1,29 @@ +from sqlite_utils.db import Index, View +import pytest + + +def test_rows(existing_db): + assert [{"text": "one"}, {"text": "two"}, {"text": "three"}] == list( + existing_db["foo"].rows + ) + + +@pytest.mark.parametrize( + "where,where_args,expected_ids", + [ + ("name = ?", ["Pancakes"], {2}), + ("age > ?", [3], {1}), + ("name is not null", [], {1, 2}), + ("is_good = ?", [True], {1, 2}), + ], +) +def test_rows_where(where, where_args, expected_ids, fresh_db): + table = fresh_db["dogs"] + table.insert_all( + [ + {"id": 1, "name": "Cleo", "age": 4, "is_good": True}, + {"id": 2, "name": "Pancakes", "age": 3, "is_good": True}, + ], + pk="id", + ) + assert expected_ids == {r["id"] for r in table.rows_where(where, where_args)}