Ejemplo n.º 1
0
    def test_formfield(self):
        field = JSONField("test")
        field.set_attributes_from_name("json")
        formfield = field.formfield()

        self.assertEqual(type(formfield), forms.CharField)
        self.assertEqual(type(formfield.widget), forms.Textarea)
Ejemplo n.º 2
0
 def test_db_prep_save(self):
     field = JSONField("test")
     field.set_attributes_from_name("json")
     self.assertEqual(None, field.get_db_prep_save(None, connection=None))
     self.assertEqual(
         '{"spam": "eggs"}',
         field.get_db_prep_save({"spam": "eggs"}, connection=None))