Matthew Schinckel avatar Matthew Schinckel committed 4f8a4a1

Removed invalid tests.
Updated readme.

Comments (0)

Files changed (3)

 database.  When you instantiate/fetch the object, it will be turned back
 into a python list/dict/string.
+If no ``default`` is provided, and ``null=True`` is not passed in to the
+field constructor, then a default of ``{}`` will be used.
 There are also a couple of other bits and bobs:


         if not self.null and value is None:
             raise ValidationError(self.error_messages['null'])
-            self.get_db_prep_value(value)
+            self.get_prep_value(value)
-            raise ValidationError(self.error_messages['invalid'])
+            raise ValidationError(self.error_messages['invalid'] % value)
     def get_default(self):
         if self.has_default():
         return value
     def get_db_prep_value(self, value, connection=None, prepared=None):
-        return self.get_db_prep_value(value)
+        return self.get_prep_value(value)
     def get_prep_value(self, value):
         if value is None:


         self.assertEquals(None, field.get_db_prep_save(None, connection=None))
         self.assertEquals('{"spam": "eggs"}', field.get_db_prep_save({"spam": "eggs"}, connection=None))
-    @unittest.expectedFailure
-    def test_value_to_string(self):
-        """
-        This is a failure because I'm not sure that value_to_string is the
-        right name for this method in django: what we are really doing is
-        preparing for serialisation. Since we want to embed the JSON object
-        in our other JSON structure, in my case, anyway, I actually want
-        this to return the python object, not a JSON serialisation of it!
-        """
-        field = JSONField(u"test")
-        field.set_attributes_from_name("json")
-        obj = JSONFieldTestModel(json='''{
-            "spam": "eggs"
-        }''')
-        self.assertEquals(u'{"spam": "eggs"}', field.value_to_string(obj))
     def test_formfield(self):
         from jsonfield.forms import JSONFormField
         from jsonfield.widgets import JSONWidget
         obj = BlankJSONFieldTestModel.objects.get()
         self.assertEquals(None, obj.null_json)
         self.assertEquals("", obj.blank_json)
-    def test_invalid_default_value(self):
-        def no_default():
-            class InvalidFieldModel(models.Model):
-                json = JSONField()
-                class Meta:
-                    app_label = 'jsonfield'
-        # self.assertRaises(AssertionError, no_default)
-        def bad_default():
-            class InvalidFieldModel(models.Model):
-                json = JSONField(default="foo")
-                class Meta:
-                    app_label = 'jsonfield'
-        self.assertRaises(AssertionError, bad_default)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.