Пример #1
0
 def test_clean_options_wrong_type(self):
     form = SeriesForm()
     form.cleaned_data = {'TEST': 1}
     with self.assertRaises(ValidationError):
         form.clean_options("TEST", {"properties": {}})
Пример #2
0
 def test_clean_options_dict_type(self):
     form = SeriesForm()
     form.cleaned_data = {'TEST': {'a': 1}}
     self.assertEquals(form.clean_options("TEST", {"properties": {"a": {"type": "integer"}}}), {'a': 1})
Пример #3
0
 def test_clean_options_none(self):
     form = SeriesForm()
     form.cleaned_data = {'TEST': None}
     self.assertEquals(form.clean_options("TEST", {"properties": {}}), None)
Пример #4
0
 def test_clean_options_invalid_json(self):
     # Note using an actual field to check errors
     form = SeriesForm()
     form.cleaned_data = {'title': '{]'}
     self.assertEquals(form.clean_options("title", {"properties": {"a": {"type": "string"}}}), None)
     self.assertTrue('title' in form.errors)
Пример #5
0
 def test_options_key_not_existing(self):
     form = SeriesForm()
     form.cleaned_data = {'TEST': '{}'}
     self.assertEquals(form.clean_options("NONE", {"properties": {}}), None)
Пример #6
0
 def test_clean_options_valid(self):
     form = SeriesForm()
     form.cleaned_data = {'TEST': '{}'}
     self.assertEquals(form.clean_options("TEST", {"properties": {}}), {})