mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
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.
This commit is contained in:
parent
dca59af6f0
commit
3960328a29
|
@ -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)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user