Skip to content

Commit

Permalink
nested genericrelation serializers not working in django 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Dec 23, 2013
1 parent b168818 commit 20de96b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/testapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def setUp(self):
instance.description = "Test"
instance.save()

# Test url="" use case
def test_list_at_root(self):
response = self.client.get("/.json")
self.assertTrue(status.is_success(response.status_code))
Expand All @@ -19,3 +20,14 @@ def test_detail_at_root(self):
response = self.client.get('/instance.json')
self.assertTrue(status.is_success(response.status_code))
self.assertTrue(response.data['description'] == "Test")

# Ensure nested serializers are created for SerializableGenericRelations
# (e.g. identifiers), but only for detail views
def test_detail_nested_identifiers(self):
response = self.client.get('/instance.json')
self.assertIn('identifiers', response.data)
self.assertEqual(response.data['identifiers'][0]['slug'], 'instance')

def test_list_nested_identifiers(self):
response = self.client.get('/.json')
self.assertNotIn('identifiers', response.data['list'][0])

0 comments on commit 20de96b

Please sign in to comment.