mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
Merge branch 'restframework2' of https://github.com/tomchristie/django-rest-framework into restframework2
This commit is contained in:
commit
ae680b13da
|
@ -409,13 +409,6 @@ class BooleanField(WritableField):
|
|||
return False
|
||||
raise ValidationError(self.error_messages['invalid'] % value)
|
||||
|
||||
class TextField(WritableField):
|
||||
type_name = 'TextField'
|
||||
|
||||
def from_native(self, value):
|
||||
if isinstance(value, basestring) or value is None:
|
||||
return value
|
||||
return smart_unicode(value)
|
||||
|
||||
class CharField(WritableField):
|
||||
type_name = 'CharField'
|
||||
|
|
|
@ -28,26 +28,6 @@ class CommentSerializer(serializers.Serializer):
|
|||
return instance
|
||||
|
||||
|
||||
class LongText(object):
|
||||
def __init__(self, content):
|
||||
self.content = content
|
||||
|
||||
def __eq__(self, other):
|
||||
return all([getattr(self, attr) == getattr(other, attr)
|
||||
for attr in ('content',)])
|
||||
|
||||
|
||||
class LongTextSerializer(serializers.Serializer):
|
||||
content = serializers.TextField()
|
||||
|
||||
def restore_object(self, data, instance=None):
|
||||
if instance is None:
|
||||
return LongText(**data)
|
||||
for key, val in data.items():
|
||||
setattr(instance, key, val)
|
||||
return instance
|
||||
|
||||
|
||||
class BasicTests(TestCase):
|
||||
def setUp(self):
|
||||
self.comment = Comment(
|
||||
|
@ -102,7 +82,6 @@ class ValidationTests(TestCase):
|
|||
'content': 'x' * 1001,
|
||||
'created': datetime.datetime(2012, 1, 1)
|
||||
}
|
||||
self.long_text = LongText('test test test test')
|
||||
|
||||
def test_create(self):
|
||||
serializer = CommentSerializer(self.data)
|
||||
|
@ -123,14 +102,6 @@ class ValidationTests(TestCase):
|
|||
self.assertEquals(serializer.is_valid(), False)
|
||||
self.assertEquals(serializer.errors, {'email': [u'This field is required.']})
|
||||
|
||||
def test_update_long_text(self):
|
||||
data = {
|
||||
'content' : 'Lorem ipsum dolor sit amet.'
|
||||
}
|
||||
serializer = LongTextSerializer(data, self.long_text)
|
||||
self.assertEquals(serializer.is_valid(), True)
|
||||
self.assertEquals(data['content'], self.long_text.content)
|
||||
|
||||
|
||||
class MetadataTests(TestCase):
|
||||
def test_empty(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user