mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 10:24:32 +02:00
table.count property, plus made a start on table documentation
This commit is contained in:
parent
0d63128c40
commit
b69f8b6c85
4 changed files with 80 additions and 1 deletions
28
tests/test_introspect.py
Normal file
28
tests/test_introspect.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from sqlite_utils import db
|
||||
import sqlite3
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def existing_db():
|
||||
database = db.Database(sqlite3.connect(":memory:"))
|
||||
database.conn.executescript(
|
||||
"""
|
||||
CREATE TABLE foo (text TEXT);
|
||||
INSERT INTO foo (text) values ("one");
|
||||
INSERT INTO foo (text) values ("two");
|
||||
INSERT INTO foo (text) values ("three");
|
||||
"""
|
||||
)
|
||||
return database
|
||||
|
||||
|
||||
def test_count(existing_db):
|
||||
assert 3 == existing_db["foo"].count
|
||||
|
||||
|
||||
def test_columns(existing_db):
|
||||
table = existing_db["foo"]
|
||||
assert [{"name": "text", "type": "TEXT"}] == [
|
||||
{"name": col.name, "type": col.type} for col in table.columns
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue