Skip to content

Commit 9b2136b

Browse files
committed
Test for NoTable and NoView exceptions
1 parent 08be98f commit 9b2136b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_create.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
ForeignKey,
99
Table,
1010
View,
11+
NoTable,
12+
NoView,
1113
)
1214
from sqlite_utils.utils import hash_record, sqlite3
1315
import collections
@@ -1367,3 +1369,14 @@ def test_create_strict(fresh_db, strict):
13671369
table = fresh_db["t"]
13681370
table.create({"id": int}, strict=strict)
13691371
assert table.strict == strict or not fresh_db.supports_strict
1372+
1373+
1374+
def test_bad_table_and_view_exceptions(fresh_db):
1375+
fresh_db.table("t").insert({"id": 1}, pk="id")
1376+
fresh_db.create_view("v", "select * from t")
1377+
with pytest.raises(NoTable) as ex:
1378+
fresh_db.table("v")
1379+
assert ex.value.args[0] == "Table v is actually a view"
1380+
with pytest.raises(NoView) as ex2:
1381+
fresh_db.view("t")
1382+
assert ex2.value.args[0] == "View t does not exist"

0 commit comments

Comments
 (0)