mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-17 06:44:19 +02:00
Separate View and Table classes
Both of these subclass a common Queryable class. Also updated documentation to cover the new View class. And added view.drop() method.
This commit is contained in:
parent
0f1f37db4d
commit
4441d6d838
4 changed files with 101 additions and 68 deletions
|
|
@ -782,3 +782,10 @@ def test_drop(fresh_db):
|
|||
assert ["t"] == fresh_db.table_names()
|
||||
assert None is fresh_db["t"].drop()
|
||||
assert [] == fresh_db.table_names()
|
||||
|
||||
|
||||
def test_drop_view(fresh_db):
|
||||
fresh_db.create_view("foo_view", "select 1")
|
||||
assert ["foo_view"] == fresh_db.view_names()
|
||||
assert None is fresh_db["foo_view"].drop()
|
||||
assert [] == fresh_db.view_names()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from sqlite_utils.db import Index
|
||||
from sqlite_utils.db import Index, View
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
@ -45,10 +45,10 @@ def test_views(fresh_db):
|
|||
fresh_db.create_view("foo_view", "select 1")
|
||||
assert 1 == len(fresh_db.views)
|
||||
view = fresh_db.views[0]
|
||||
assert view.is_view
|
||||
assert view.exists
|
||||
assert isinstance(view, View)
|
||||
assert "foo_view" == view.name
|
||||
assert "<View foo_view (1)>" == repr(view)
|
||||
assert {"1": str} == view.columns_dict
|
||||
|
||||
|
||||
def test_count(existing_db):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue