Add datetime and timestamp fields
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from datetime import datetime
|
||||
from pprint import pprint as print
|
||||
from time import sleep
|
||||
|
||||
import pytest
|
||||
from tinydb import Query
|
||||
@@ -133,3 +135,14 @@ def test_password(db):
|
||||
assert check("fnord", user.password)
|
||||
assert not check("wrong password", user.password)
|
||||
assert not check("", user.password)
|
||||
|
||||
|
||||
def test_datetime(db):
|
||||
user = db.save(examples.User(name="john", email="john@foo", password="fnord", created=datetime.utcnow()))
|
||||
assert user.created > datetime.utcfromtimestamp(0)
|
||||
assert user.created < datetime.utcnow()
|
||||
assert user.last_updated == user.created
|
||||
|
||||
sleep(1)
|
||||
user = db.save(user)
|
||||
assert user.last_updated >= user.created
|
||||
|
||||
Reference in New Issue
Block a user