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

Do not return bytes, but str #485

Merged
merged 5 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion nailgun/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4383,7 +4383,8 @@ def download_debug_certificate(self, synchronous=True, **kwargs):
kwargs.update(self._server_config.get_client_kwargs())
response = client.get(
self.path('download_debug_certificate'), **kwargs)
return _handle_response(response, self._server_config, synchronous)
return _handle_response(response, self._server_config, synchronous) \
.decode('utf-8')


class OSDefaultTemplate(
Expand Down
11 changes: 10 additions & 1 deletion tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,8 @@ def setUpClass(cls):
entity_obj3.method2, 'put',
)

``decoded_responses`` is a tuple of methods whose result was decoded
into string.
"""
cfg = config.ServerConfig('http://example.com')
generic = {'server_config': cfg, 'id': 1}
Expand Down Expand Up @@ -1742,6 +1744,9 @@ def setUpClass(cls):
(entities.SyncPlan(**sync_plan).add_products, 'put'),
(entities.SyncPlan(**sync_plan).remove_products, 'put'),
)
cls.decoded_responses = (
entities.Organization(**generic).download_debug_certificate,
)

def test_generic(self):
"""Check that a variety of helper methods are sane.
Expand Down Expand Up @@ -1769,7 +1774,11 @@ def test_generic(self):
self.assertEqual(len(client_request.call_args[0]), 1)
self.assertEqual(client_request.call_args[1], kwargs)
self.assertEqual(handlr.call_count, 1)
self.assertEqual(handlr.return_value, response)
if method in self.decoded_responses:
self.assertEqual(handlr.return_value.decode('utf-8'),
response)
else:
self.assertEqual(handlr.return_value, response)


class AbstractDockerContainerTestCase(TestCase):
Expand Down