Skip to content

Commit

Permalink
Fix tests using sqlalchemy attrs history
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Feb 22, 2019
1 parent 2a8550a commit 82ccb55
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions unrest/tests/flask/test_validators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from datetime import timedelta

from sqlalchemy.inspection import inspect

from . import idsorted
from ..model import Fruit, Tree

Expand Down Expand Up @@ -128,14 +130,14 @@ def name_validator(field):

def test_put_fruit_dual_validation(rest, http):
def color_validator(field):
if field.previous.color == 'brown':
if inspect(field.item).attrs.color.history.deleted[0] == 'brown':
raise field.ValidationError(
'A brown fruit cannot become %s' % field.value
)
return field.value

def size_validator(field):
if field.value > 48.9 and field.next.age < timedelta(weeks=2):
if field.value > 48.9 and field.item.age < timedelta(weeks=2):
raise rest.ValidationError('Fruit too big for its age')
return field.value

Expand Down

0 comments on commit 82ccb55

Please sign in to comment.