2016-06-17 19:29:38 +03:00
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
from py.test import raises
|
|
|
|
|
|
|
|
from ..forms import GlobalIDFormField
|
|
|
|
|
|
|
|
|
|
|
|
# 'TXlUeXBlOmFiYw==' -> 'MyType', 'abc'
|
|
|
|
|
|
|
|
|
|
|
|
def test_global_id_valid():
|
|
|
|
field = GlobalIDFormField()
|
2016-09-11 07:22:42 +03:00
|
|
|
field.clean('TXlUeXBlOmFiYw==')
|
2016-06-17 19:29:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_global_id_invalid():
|
|
|
|
field = GlobalIDFormField()
|
|
|
|
with raises(ValidationError):
|
|
|
|
field.clean('badvalue')
|
|
|
|
|
|
|
|
|
|
|
|
def test_global_id_none():
|
|
|
|
field = GlobalIDFormField()
|
|
|
|
with raises(ValidationError):
|
|
|
|
field.clean(None)
|
|
|
|
|
|
|
|
|
|
|
|
def test_global_id_none_optional():
|
|
|
|
field = GlobalIDFormField(required=False)
|
|
|
|
field.clean(None)
|