Example #1
0
 def test_formfield(self):
     from jsonfield.forms import JSONFormField
     from jsonfield.widgets import JSONWidget
     field = JSONField("test")
     field.set_attributes_from_name("json")
     formfield = field.formfield()
     self.assertEquals(type(formfield), JSONFormField)
     self.assertEquals(type(formfield.widget), JSONWidget)
Example #2
0
 def test_formfield_blank_clean_none(self):
     field = JSONField("test", null=False, blank=True)
     formfield = field.formfield()
     self.assertEquals(formfield.clean(value=None), '')
Example #3
0
 def test_formfield_null_and_blank_clean_blank(self):
     field = JSONField("test", null=True, blank=True)
     formfield = field.formfield()
     self.assertEquals(formfield.clean(value=''), '')
Example #4
0
 def test_formfield_clean_none(self):
     field = JSONField("test")
     formfield = field.formfield()
     self.assertRaisesMessage(forms.ValidationError, force_text(formfield.error_messages['required']), formfield.clean, value=None)
Example #5
0
 def test_formfield_blank_clean_none(self):
     # Hmm, I'm not sure how to do this. What happens if we pass a
     # None to a field that has null=False?
     field = JSONField("test", null=False, blank=True)
     formfield = field.formfield()
     self.assertEqual(formfield.clean(value=None), None)
Example #6
0
 def test_formfield_null_and_blank_clean_none(self):
     field = JSONField("test", null=True, blank=True)
     formfield = field.formfield()
     self.assertEqual(formfield.clean(value=None), None)
Example #7
0
 def test_formfield_blank_clean_none(self):
     # Hmm, I'm not sure how to do this. What happens if we pass a
     # None to a field that has null=False?
     field = JSONField("test", null=False, blank=True)
     formfield = field.formfield()
     self.assertEqual(formfield.clean(value=None), None)
Example #8
0
 def test_formfield_blank_clean_blank(self):
     field = JSONField("test", null=False, blank=True)
     formfield = field.formfield()
     self.assertEqual(formfield.clean(value=''), '')