sqlite-utils/tests/test_get.py
2019-07-14 11:58:40 -07:00

22 lines
626 B
Python

import pytest
@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)}