Add basic database test
This commit is contained in:
parent
9f2c9d14d3
commit
8a4d666248
|
@ -1,5 +0,0 @@
|
|||
from amanuensis import __version__
|
||||
|
||||
|
||||
def test_version():
|
||||
assert __version__ == '0.1.0'
|
|
@ -0,0 +1,25 @@
|
|||
import pytest
|
||||
from sqlalchemy import func
|
||||
|
||||
from amanuensis.database import DbContext
|
||||
from amanuensis.models import *
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def session():
|
||||
db = DbContext('sqlite:///:memory:', debug=True)
|
||||
db.create_all()
|
||||
return db.session
|
||||
|
||||
|
||||
def test_create(session):
|
||||
"""Simple test that the database creates fine from scratch."""
|
||||
assert session.query(func.count(User.id)).scalar() == 0
|
||||
assert session.query(func.count(Lexicon.id)).scalar() == 0
|
||||
assert session.query(func.count(Membership.id)).scalar() == 0
|
||||
assert session.query(func.count(Character.id)).scalar() == 0
|
||||
assert session.query(func.count(Article.id)).scalar() == 0
|
||||
assert session.query(func.count(ArticleIndex.id)).scalar() == 0
|
||||
assert session.query(func.count(ArticleIndexRule.id)).scalar() == 0
|
||||
assert session.query(func.count(ArticleContentRule.id)).scalar() == 0
|
||||
assert session.query(func.count(Post.id)).scalar() == 0
|
Loading…
Reference in New Issue