Rework test matrix and structure

This commit is contained in:
Sebastien Corbin
2020-04-18 18:53:42 +02:00
parent c5f7c10d23
commit 622f3ea10b
15 changed files with 127 additions and 149 deletions

27
tests/test_forms.py Normal file
View File

@@ -0,0 +1,27 @@
from django.test import SimpleTestCase
from django.core.exceptions import ValidationError
from jsignature.widgets import JSignatureWidget
from jsignature.forms import JSignatureField
class JSignatureFormFieldTest(SimpleTestCase):
def test_widget(self):
f = JSignatureField()
self.assertIsInstance(f.widget, JSignatureWidget)
def test_to_python_empty_values(self):
f = JSignatureField()
for val in ['', [], '[]']:
self.assertIsNone(f.to_python(val))
def test_to_python_correct_values(self):
f = JSignatureField()
val = '[{"x":[1,2], "y":[3,4]}]'
self.assertEquals([{'x': [1, 2], 'y': [3, 4]}], f.to_python(val))
def test_to_python_incorrect_values(self):
f = JSignatureField()
val = 'foo'
self.assertRaises(ValidationError, f.to_python, val)