WIP
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
import ttfrog.app
|
||||
from ttfrog import schema
|
||||
from ttfrog.db import Database
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
ttfrog.app.initialize(Database("ttfrog-tests"))
|
||||
ttfrog.app.db.drop_tables()
|
||||
yield ttfrog.app
|
||||
ttfrog.app.db.close()
|
||||
os.unlink("ttfrog-tests")
|
||||
|
||||
|
||||
def test_create(app):
|
||||
user = schema.User(name="john", email="john@foo")
|
||||
assert user.uid
|
||||
assert user._metadata.fields["uid"].unique
|
||||
|
||||
# insert
|
||||
john_something = app.db.save(user)
|
||||
last_insert_id = john_something.doc_id
|
||||
|
||||
# read back
|
||||
assert app.db.User.get(doc_id=last_insert_id) == john_something
|
||||
assert john_something.name == user.name
|
||||
assert john_something.email == user.email
|
||||
assert john_something.uid == user.uid
|
||||
|
||||
# update
|
||||
john_something.name = "james?"
|
||||
before_update = app.db.User.get(doc_id=john_something.doc_id)
|
||||
after_update = app.db.save(john_something)
|
||||
assert after_update == john_something
|
||||
assert before_update != after_update
|
||||
@@ -1,8 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from ttfrog import cli
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_tests_are_implemented():
|
||||
assert cli.main()
|
||||
Reference in New Issue
Block a user