mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-12 03:24:23 +02:00
Test for NoTable and NoView exceptions
This commit is contained in:
parent
08be98f5d6
commit
9b2136b1f4
1 changed files with 13 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ from sqlite_utils.db import (
|
|||
ForeignKey,
|
||||
Table,
|
||||
View,
|
||||
NoTable,
|
||||
NoView,
|
||||
)
|
||||
from sqlite_utils.utils import hash_record, sqlite3
|
||||
import collections
|
||||
|
|
@ -1367,3 +1369,14 @@ def test_create_strict(fresh_db, strict):
|
|||
table = fresh_db["t"]
|
||||
table.create({"id": int}, strict=strict)
|
||||
assert table.strict == strict or not fresh_db.supports_strict
|
||||
|
||||
|
||||
def test_bad_table_and_view_exceptions(fresh_db):
|
||||
fresh_db.table("t").insert({"id": 1}, pk="id")
|
||||
fresh_db.create_view("v", "select * from t")
|
||||
with pytest.raises(NoTable) as ex:
|
||||
fresh_db.table("v")
|
||||
assert ex.value.args[0] == "Table v is actually a view"
|
||||
with pytest.raises(NoView) as ex2:
|
||||
fresh_db.view("t")
|
||||
assert ex2.value.args[0] == "View t does not exist"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue