Skip to content

Commit

Permalink
Merge pull request #7 from nvllsvm/dev
Browse files Browse the repository at this point in the history
Avoid double-quoting the resource path
  • Loading branch information
dave-shawley authored Jul 3, 2017
2 parents 0cac4c9 + 56f8f21 commit 79c3562
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions glinda/testing/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,17 @@ def add_endpoint(self, *path):
:meth:`.add_response` which will create the resource if necessary.
"""
url = _quote_path(*path)
if url not in self._endpoints:
self.add_resource_callback(self, url)
self._endpoints.add(url)
self._register_endpoint(_quote_path(*path))

def _register_endpoint(self, path):
"""
Register an endpoint with with this service.
:param path: quoted resource path
"""
if path not in self._endpoints:
self.add_resource_callback(self, path)
self._endpoints.add(path)

def add_response(self, request, response):
"""
Expand All @@ -224,7 +231,7 @@ def add_response(self, request, response):
handler receives `request`
"""
self.add_endpoint(request.resource)
self._register_endpoint(request.resource)
self._responses[request.method, request.resource].append(response)

def record_request(self, request):
Expand Down
4 changes: 2 additions & 2 deletions tests/testing_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def test_that_endpoint_responds_with_456_by_default(self):
@tornado.testing.gen_test
def test_that_endpoint_responds_with_programmed_response(self):
service = self.service_layer['service']
service.add_response(services.Request('GET', '/resource'),
service.add_response(services.Request('GET', '/resource:test'),
services.Response(222))

client = httpclient.AsyncHTTPClient()
response = yield client.fetch(service.url_for('resource'))
response = yield client.fetch(service.url_for('resource:test'))
self.assertEqual(response.code, 222)


Expand Down

0 comments on commit 79c3562

Please sign in to comment.