From 456c3f2cd8bbf6a8e99e41dd1ddd130c20c0262e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 18 Aug 2015 15:55:09 +0200 Subject: [PATCH] Add a test that checks links on APIs linked from root This test clicks on each link on API root and checks that rendering the documentation there does not log any errors. This is not perfect in that views not listed on API root will not be tested. --- pdc/apps/common/tests.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pdc/apps/common/tests.py b/pdc/apps/common/tests.py index aa6a5bb6..68b647a5 100644 --- a/pdc/apps/common/tests.py +++ b/pdc/apps/common/tests.py @@ -420,3 +420,12 @@ def test_filter_set_has_details(self): ' * `key_id` (string)\n' ' * `name` (string)' ) + + +class AutoUrlsTestCase(APITestCase): + def test_no_autolink_logs_error(self): + root = self.client.get(reverse('api-root')) + for _, url in root.data.iteritems(): + with mock.patch('logging.getLogger') as getLogger: + self.client.get(url, HTTP_ACCEPT='text/html') + self.assertFalse(getLogger.return_value.error.called, "%s has bad link" % url)