1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Reverting r14994 (at request of SmileyChris) because of some backwards compatibility issues that need to be resolved.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14995 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2010-12-21 06:05:40 +00:00
parent b60d5df072
commit e299ac0cae
6 changed files with 25 additions and 109 deletions

View File

@@ -414,36 +414,8 @@ def streamTest(format, self):
self.assertEqual(string_data, stream.getvalue())
stream.close()
def naturalKeyTest(format, self):
book1 = {'isbn13': '978-1590597255', 'title': 'The Definitive Guide to '
'Django: Web Development Done Right'}
book2 = {'isbn13':'978-1590599969', 'title': 'Practical Django Projects'}
# Create the books.
adrian = Book.objects.create(**book1)
james = Book.objects.create(**book2)
# Serialize the books.
string_data = serializers.serialize(format, Book.objects.all(), indent=2,
use_natural_keys=True)
# Delete one book (to prove that the natural key generation will only
# restore the primary keys of books found in the database via the
# get_natural_key manager method).
james.delete()
# Deserialize and test.
books = list(serializers.deserialize(format, string_data))
self.assertEqual(len(books), 2)
self.assertEqual(books[0].object.title, book1['title'])
self.assertEqual(books[0].object.pk, adrian.pk)
self.assertEqual(books[1].object.title, book2['title'])
self.assertEqual(books[1].object.pk, None)
for format in serializers.get_serializer_formats():
setattr(SerializerTests, 'test_' + format + '_serializer', curry(serializerTest, format))
setattr(SerializerTests, 'test_' + format + '_serializer_fields', curry(fieldsTest, format))
setattr(SerializerTests, 'test_' + format + '_serializer_natural_key',
curry(naturalKeyTest, format))
if format != 'python':
setattr(SerializerTests, 'test_' + format + '_serializer_stream', curry(streamTest, format))