Skip to content

Write failing test scenario to support issue #4463. #4464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,36 @@ def test_view(self):
}
)
self.assertEquals(schema, expected)


class SnippetListView(APIView):
def get(self, *args, **kwargs):
pass


class SnippetDetailView(APIView):
def get(self, *args, **kwargs):
pass


@unittest.skipUnless(coreapi, 'coreapi is not installed')
class TestDocumentLinksOnExplicitlyDefinedPatterns(TestCase):
"""
Given a "list" and "detail" view with explicitly defined urlpatterns,
and that the views support common HTTP methods, Document Link objects
should be created for both the "list" and "detail" endpoints.
"""
def setUp(self):
self.patterns = [
url('^snippets/?$', SnippetListView.as_view()),
url('^snippets/(?P<pk>\d+)/?$', SnippetDetailView.as_view()),
]
self.generator = SchemaGenerator(title='Test View', patterns=self.patterns)
self.document = self.generator.get_schema()

def test_there_should_be_a_link_to_the_snippets_list_view(self):
expected = '/snippets/'
snippets = self.document._data['snippets']
urls = [link.url for link in snippets._data.values()]

self.assertIn(expected, urls)