From 3960328a29a21a7ccb3ce89cd2ef174d4379490b Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov Date: Tue, 23 May 2017 17:18:13 +0300 Subject: [PATCH] Add tests for documentation code snippets We check for Python and JS code (they have the same syntax for the action list), and shell code snippets, ensuring that the action is correct for the nested routes. --- tests/interactive_doc/test_recursive_url.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/interactive_doc/test_recursive_url.py b/tests/interactive_doc/test_recursive_url.py index 64b313052..9dd54a991 100644 --- a/tests/interactive_doc/test_recursive_url.py +++ b/tests/interactive_doc/test_recursive_url.py @@ -41,3 +41,15 @@ class TestRecursiveUrlViewSets(TestCase): re.search(header_re.format(level=3, path=subpath, title=method), self.content), 'unable to find documentation section for {}'.format(subpath) ) + action_code = 'action = [{}, "retrieve_alt", "{}"]'.format( + ", ".join('"{}"'.format(r) for r in route), + method + ) + self.assertTrue( + action_code in self.content.replace('"', '"'), + 'unable to find code snippet for {}'.format(subpath) + ) + self.assertTrue( + '$ coreapi action {} retrieve_alt {}'.format(' '.join(route), method) in self.content, + 'unable to find shell code snippet for {}'.format(subpath) + )