mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-13 12:54:12 +02:00
Use db.table() and db.view() in tests, closes #838
This commit is contained in:
parent
43d5d3331f
commit
38fe466700
43 changed files with 1321 additions and 1254 deletions
|
|
@ -13,7 +13,7 @@ from sqlite_utils import Database, cli
|
|||
def test_db_and_path(tmpdir):
|
||||
db_path = str(pathlib.Path(tmpdir) / "data.db")
|
||||
db = Database(db_path)
|
||||
db["example"].insert_all(
|
||||
db.table("example").insert_all(
|
||||
[
|
||||
{"id": 1, "name": "One"},
|
||||
{"id": 2, "name": "Two"},
|
||||
|
|
@ -44,7 +44,7 @@ def test_cli_bulk(test_db_and_path):
|
|||
{"id": 2, "name": "Two"},
|
||||
{"id": 3, "name": "THREE"},
|
||||
{"id": 4, "name": "FOUR"},
|
||||
] == list(db["example"].rows)
|
||||
] == list(db.table("example").rows)
|
||||
|
||||
|
||||
def test_cli_bulk_multiple_functions(test_db_and_path):
|
||||
|
|
@ -70,7 +70,7 @@ def test_cli_bulk_multiple_functions(test_db_and_path):
|
|||
{"id": 2, "name": "Two"},
|
||||
{"id": 3, "name": "THREE"},
|
||||
{"id": 4, "name": "FOUR"},
|
||||
] == list(db["example"].rows)
|
||||
] == list(db.table("example").rows)
|
||||
|
||||
|
||||
def test_cli_bulk_batch_size(test_db_and_path):
|
||||
|
|
@ -95,13 +95,13 @@ def test_cli_bulk_batch_size(test_db_and_path):
|
|||
proc.stdin.write(b'{"id": 3, "name": "Three"}\n\n')
|
||||
proc.stdin.flush()
|
||||
time.sleep(1)
|
||||
assert db["example"].count == 2
|
||||
assert db.table("example").count == 2
|
||||
|
||||
# Writing another should trigger a commit:
|
||||
proc.stdin.write(b'{"id": 4, "name": "Four"}\n\n')
|
||||
proc.stdin.flush()
|
||||
time.sleep(1)
|
||||
assert db["example"].count == 4
|
||||
assert db.table("example").count == 4
|
||||
|
||||
proc.stdin.close()
|
||||
proc.wait()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue