Esempio n. 1
0
    def test_jsonfield_rejects_invalid_json(self):
        invalid_json = "{this isnt valid"
        field = JSONField()

        with self.assertRaises(ValidationError):
            field.clean(invalid_json)
Esempio n. 2
0
 def test_jsonfield_accepts_valid_json(self):
     valid_json = json.dumps({"a": True, 2: ["b", 3, 4.0]})
     field = JSONField()
     cleaned = field.clean(valid_json)
     self.assertEqual(cleaned, valid_json)