Пример #1
0
 def test_to_internal_value_invalid_choices(self):
     """Test that choices still matter, and you can't a) send the internal
     value or b) send an invalid value."""
     field = ReverseChoiceField(choices=(('internal', 'human'),))
     with self.assertRaises(serializers.ValidationError):
         field.to_internal_value('internal')
Пример #2
0
 def test_to_internal_value_invalid_choices(self):
     """Test that choices still matter, and you can't a) send the internal
     value or b) send an invalid value."""
     field = ReverseChoiceField(choices=(('internal', 'human'),))
     with self.assertRaises(serializers.ValidationError):
         field.to_internal_value('internal')
Пример #3
0
 def test_to_internal_value(self):
     """Test that when a client sends data in human-readable format
     (e.g. a string constant), we convert it to the internal format when
     converting data to internal value."""
     field = ReverseChoiceField(choices=(('internal', 'human'),))
     assert field.to_internal_value('human') == 'internal'
Пример #4
0
 def test_to_internal_value(self):
     """Test that when a client sends data in human-readable format
     (e.g. a string constant), we convert it to the internal format when
     converting data to internal value."""
     field = ReverseChoiceField(choices=(('internal', 'human'),))
     assert field.to_internal_value('human') == 'internal'