Refactored tests into new test_rows.py, refs #76

This commit is contained in:
Simon Willison 2020-04-15 18:04:51 -07:00
commit fc38868bd4
3 changed files with 29 additions and 27 deletions

View file

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