--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<response><resource><kind></kind><full_sort_key>$child$2</full_sort_key><title>Child</title><url>https://example.com/katalog/lektura/child/</url><has_audio>False</has_audio><author></author><cover></cover><slug>child</slug><epoch></epoch><href>https://example.com/api/books/child/</href><genre>Wiersz</genre><simple_thumb></simple_thumb><cover_color>#000000</cover_color><cover_thumb></cover_thumb></resource><resource><kind></kind><full_sort_key>$grandchild$3</full_sort_key><title>Grandchild</title><url>https://example.com/katalog/lektura/grandchild/</url><has_audio>False</has_audio><author></author><cover></cover><slug>grandchild</slug><epoch></epoch><href>https://example.com/api/books/grandchild/</href><genre>Sonet</genre><simple_thumb></simple_thumb><cover_color>#000000</cover_color><cover_thumb></cover_thumb></resource><resource><kind>Liryka</kind><full_sort_key>john doe$parent$1</full_sort_key><title>Parent</title><url>https://example.com/katalog/lektura/parent/</url><has_audio>True</has_audio><author>John Doe</author><cover>cover/parent.jpg</cover><slug>parent</slug><epoch>Barok</epoch><href>https://example.com/api/books/parent/</href><genre>Sonet</genre><simple_thumb>https://example.com/media/cover_api_thumb/parent.jpg</simple_thumb><cover_color>#a6820a</cover_color><cover_thumb>https://example.com/media/cover/parent.jpg-139x193</cover_thumb></resource></response>
+
[
{
"url": "https://example.com/katalog/lektury/a-collection/",
- "href": "https://example.com/dapi/collections/a-collection/",
+ "href": "https://example.com/api/collections/a-collection/",
"title": "A Collection"
}
]
self.fail('No JSON could be decoded: %s' % content)
return data
+ def assert_response(self, url, name):
+ content = self.client.get(url).content.rstrip()
+ filename = path.join(path.dirname(__file__), 'res', 'responses', name)
+ with open(filename) as f:
+ good_content = f.read().rstrip()
+ self.assertEqual(content, good_content, content)
+
def assert_json_response(self, url, name):
data = self.load_json(url)
filename = path.join(path.dirname(__file__), 'res', 'responses', name)
def test_books(self):
self.assert_json_response('/api/books/', 'books.json')
self.assert_json_response('/api/books/?new_api=true', 'books.json')
+ self.assert_response('/api/books/?format=xml', 'books.xml')
self.assert_slugs('/api/audiobooks/', ['parent'])
self.assert_slugs('/api/daisy/', ['parent'])