Skip to content
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

Added unit test for issue 810. #893

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions eve/methods/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,8 @@ def resource_link():
"""
path = request.path.strip('/')

assert request.routing_exception is None, 'Routing error for %s: %s' % (request.url, request.routing_exception)

if '|item' in request.endpoint:
path = path[:path.rfind('/')]

Expand Down
21 changes: 21 additions & 0 deletions eve/tests/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@ def test_api_prefix(self):
r = self.test_prefix.get('/prefix/contacts/')
self.assert200(r.status_code)

r = self.test_prefix.post('/prefix/contacts/', data='{}',
content_type='application/json')
self.assert201(r.status_code)

def test_api_prefix_post_internal(self):
from eve.methods.post import post_internal

settings_file = os.path.join(self.this_directory, 'test_prefix.py')
self.app = Eve(settings=settings_file)
self.test_prefix = self.app.test_client()

# This works fine
with self.app.test_request_context(method='POST', path='/prefix/contacts'):
r, _, _, status_code = post_internal('contacts', {})
self.assert201(status_code)

# This fails
with self.app.test_request_context():
r, _, _, status_code = post_internal('contacts', {})
self.assert201(status_code)

def test_api_prefix_version(self):
settings_file = os.path.join(self.this_directory,
'test_prefix_version.py')
Expand Down
1 change: 1 addition & 0 deletions eve/tests/test_prefix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-

RESOURCE_METHODS = ['GET', 'POST']
URL_PREFIX = 'prefix'
DOMAIN = {'contacts': {}}