Skip to content

Commit b9909c6

Browse files
committed
exec_resize is incorrectly passing param as json
1 parent bd5eaed commit b9909c6

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

docker/client.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,11 @@ def exec_resize(self, exec_id, height=None, width=None):
567567
raise errors.InvalidVersion('Exec is not supported in API < 1.15')
568568
if isinstance(exec_id, dict):
569569
exec_id = exec_id.get('Id')
570-
data = {
571-
'h': height,
572-
'w': width
573-
}
574-
res = self._post_json(
575-
self._url('/exec/{0}/resize'.format(exec_id)), data
576-
)
577-
res.raise_for_status()
570+
571+
params = {'h': height, 'w': width}
572+
url = self._url("/exec/{0}/resize".format(exec_id))
573+
res = self._post(url, params=params)
574+
self._raise_for_status(res)
578575

579576
def exec_start(self, exec_id, detach=False, tty=False, stream=False):
580577
if utils.compare_version('1.15', self._version) < 0:

tests/test.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,22 +1662,10 @@ def test_exec_resize(self):
16621662
except Exception as e:
16631663
self.fail('Command should not raise exception: {0}'.format(e))
16641664

1665-
args = fake_request.call_args
1666-
self.assertEqual(
1667-
args[0][0], url_prefix + 'exec/{0}/resize'.format(
1668-
fake_api.FAKE_EXEC_ID
1669-
)
1670-
)
1671-
1672-
self.assertEqual(
1673-
json.loads(args[1]['data']), {
1674-
'h': 20,
1675-
'w': 60,
1676-
}
1677-
)
1678-
1679-
self.assertEqual(
1680-
args[1]['headers'], {'Content-Type': 'application/json'}
1665+
fake_request.assert_called_with(
1666+
url_prefix + 'exec/{0}/resize'.format(fake_api.FAKE_EXEC_ID),
1667+
params={'h': 20, 'w': 60},
1668+
timeout=DEFAULT_TIMEOUT_SECONDS
16811669
)
16821670

16831671
def test_pause_container(self):

0 commit comments

Comments
 (0)