mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-25 11:04:11 +03:00
9a773b9d7b
* Use ruff in pre-commit * Add pyupgrade * Add isort * Add bugbear * Fix B015 Pointless comparison * Fix B026 * B018 false positive * Remove flake8 and isort config from setup.cfg * Remove black and flake8 from dev dependencies * Update black * Show list of fixes applied with autofix on * Fix typo * Add C4 flake8-comprehensions * Add ruff to dev dependencies * Fix up
40 lines
951 B
Python
40 lines
951 B
Python
from django.core.exceptions import ValidationError
|
|
from pytest import raises
|
|
|
|
from ..forms import GlobalIDFormField, GlobalIDMultipleChoiceField
|
|
|
|
# 'TXlUeXBlOmFiYw==' -> 'MyType', 'abc'
|
|
|
|
|
|
def test_global_id_valid():
|
|
field = GlobalIDFormField()
|
|
field.clean("TXlUeXBlOmFiYw==")
|
|
|
|
|
|
def test_global_id_invalid():
|
|
field = GlobalIDFormField()
|
|
with raises(ValidationError):
|
|
field.clean("badvalue")
|
|
|
|
|
|
def test_global_id_multiple_valid():
|
|
field = GlobalIDMultipleChoiceField()
|
|
field.clean(["TXlUeXBlOmFiYw==", "TXlUeXBlOmFiYw=="])
|
|
|
|
|
|
def test_global_id_multiple_invalid():
|
|
field = GlobalIDMultipleChoiceField()
|
|
with raises(ValidationError):
|
|
field.clean(["badvalue", "another bad avue"])
|
|
|
|
|
|
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)
|