From: Radek Czajka Date: Wed, 23 Jan 2019 00:03:18 +0000 (+0100) Subject: You forgot XML. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/1123ad09c5b6b23721639c9a1454fd80999759ee You forgot XML. --- diff --git a/src/api/tests/res/responses/books.xml b/src/api/tests/res/responses/books.xml new file mode 100644 index 000000000..967f8e2ed --- /dev/null +++ b/src/api/tests/res/responses/books.xml @@ -0,0 +1,3 @@ + +$child$2Childhttps://example.com/katalog/lektura/child/Falsechildhttps://example.com/api/books/child/Wiersz#000000$grandchild$3Grandchildhttps://example.com/katalog/lektura/grandchild/Falsegrandchildhttps://example.com/api/books/grandchild/Sonet#000000Lirykajohn doe$parent$1Parenthttps://example.com/katalog/lektura/parent/TrueJohn Doecover/parent.jpgparentBarokhttps://example.com/api/books/parent/Sonethttps://example.com/media/cover_api_thumb/parent.jpg#a6820ahttps://example.com/media/cover/parent.jpg-139x193 + diff --git a/src/api/tests/res/responses/collections.json b/src/api/tests/res/responses/collections.json index a0852cdb0..db583243e 100644 --- a/src/api/tests/res/responses/collections.json +++ b/src/api/tests/res/responses/collections.json @@ -1,7 +1,7 @@ [ { "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" } ] diff --git a/src/api/tests/tests.py b/src/api/tests/tests.py index ccee689f9..adaaa6002 100644 --- a/src/api/tests/tests.py +++ b/src/api/tests/tests.py @@ -39,6 +39,13 @@ class ApiTest(TestCase): 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) @@ -130,6 +137,7 @@ class BooksTests(ApiTest): 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']) diff --git a/src/wolnelektury/settings/test.py b/src/wolnelektury/settings/test.py index 0ad0e6988..25bd82caf 100644 --- a/src/wolnelektury/settings/test.py +++ b/src/wolnelektury/settings/test.py @@ -2,3 +2,4 @@ from wolnelektury.settings import * THUMBNAIL_BACKEND = 'wolnelektury.test_utils.DummyThumbnailBackend' CATALOGUE_GET_MP3_LENGTH = 'catalogue.test_utils.get_mp3_length' +MEDIA_URL = '/media/'