mirror of https://github.com/docker/docker-py.git
Raising error in case of invalid value of since kwarg on Container.logs
Signed-off-by: Chris Mark <chrismarkou92@gmail.com>
This commit is contained in:
parent
8fc6540fea
commit
c03a009e2d
|
|
@ -825,6 +825,11 @@ class ContainerApiMixin(object):
|
||||||
params['since'] = utils.datetime_to_timestamp(since)
|
params['since'] = utils.datetime_to_timestamp(since)
|
||||||
elif (isinstance(since, int) and since > 0):
|
elif (isinstance(since, int) and since > 0):
|
||||||
params['since'] = since
|
params['since'] = since
|
||||||
|
else:
|
||||||
|
raise errors.InvalidArgument(
|
||||||
|
'since value should be datetime or int, not {}'.
|
||||||
|
format(type(since))
|
||||||
|
)
|
||||||
url = self._url("/containers/{0}/logs", container)
|
url = self._url("/containers/{0}/logs", container)
|
||||||
res = self._get(url, params=params, stream=stream)
|
res = self._get(url, params=params, stream=stream)
|
||||||
return self._get_result(container, stream, res)
|
return self._get_result(container, stream, res)
|
||||||
|
|
|
||||||
|
|
@ -1421,6 +1421,13 @@ class ContainerTest(BaseAPIClientTest):
|
||||||
stream=False
|
stream=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_log_since_with_invalid_value_raises_error(self):
|
||||||
|
with mock.patch('docker.api.client.APIClient.inspect_container',
|
||||||
|
fake_inspect_container):
|
||||||
|
with self.assertRaises(docker.errors.InvalidArgument):
|
||||||
|
self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False,
|
||||||
|
follow=False, since=42.42)
|
||||||
|
|
||||||
def test_log_tty(self):
|
def test_log_tty(self):
|
||||||
m = mock.Mock()
|
m = mock.Mock()
|
||||||
with mock.patch('docker.api.client.APIClient.inspect_container',
|
with mock.patch('docker.api.client.APIClient.inspect_container',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue