diff options
| author | Daniel Nephin <dnephin@gmail.com> | 2015-11-12 14:07:54 -0500 |
|---|---|---|
| committer | Daniel Nephin <dnephin@gmail.com> | 2015-11-12 14:07:54 -0500 |
| commit | 6e73f04acc16f847c64a7d14cd9cdfd810b8a515 (patch) | |
| tree | ed26699db7462349183d337097ad9948b4399ed4 /tests | |
| parent | c89d3668274cd8de11d1521c876771c5e4f4fc8f (diff) | |
| parent | 33305697728ec661d01eb4f596b20eae565fda42 (diff) | |
| download | docker-py-6e73f04acc16f847c64a7d14cd9cdfd810b8a515.tar.gz | |
Merge pull request #796 from v-boyko/feature/logs_since
Support the 'since' option in the 'containers/<id>/logs' endpoint (API upgrade)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/container_test.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/unit/container_test.py b/tests/unit/container_test.py index eeeba76..2516c8f 100644 --- a/tests/unit/container_test.py +++ b/tests/unit/container_test.py @@ -1,3 +1,4 @@ +import datetime import json import signal @@ -1080,6 +1081,7 @@ class ContainerTest(DockerClientTest): ) def test_log_tail(self): + with mock.patch('docker.Client.inspect_container', fake_inspect_container): self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False, @@ -1094,6 +1096,39 @@ class ContainerTest(DockerClientTest): stream=False ) + def test_log_since(self): + ts = 809222400 + with mock.patch('docker.Client.inspect_container', + fake_inspect_container): + self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False, + since=ts) + + fake_request.assert_called_with( + 'GET', + url_prefix + 'containers/3cc2351ab11b/logs', + params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1, + 'tail': 'all', 'since': ts}, + timeout=DEFAULT_TIMEOUT_SECONDS, + stream=False + ) + + def test_log_since_with_datetime(self): + ts = 809222400 + time = datetime.datetime.utcfromtimestamp(ts) + with mock.patch('docker.Client.inspect_container', + fake_inspect_container): + self.client.logs(fake_api.FAKE_CONTAINER_ID, stream=False, + since=time) + + fake_request.assert_called_with( + 'GET', + url_prefix + 'containers/3cc2351ab11b/logs', + params={'timestamps': 0, 'follow': 0, 'stderr': 1, 'stdout': 1, + 'tail': 'all', 'since': ts}, + timeout=DEFAULT_TIMEOUT_SECONDS, + stream=False + ) + def test_log_tty(self): m = mock.Mock() with mock.patch('docker.Client.inspect_container', |
