diff options
| author | Huayi Zhang <irachex@gmail.com> | 2014-10-05 23:06:42 +0800 |
|---|---|---|
| committer | Huayi Zhang <irachex@gmail.com> | 2014-10-05 23:18:48 +0800 |
| commit | 589e7006d59273dcc122d9d0bf2c73aa7190832d (patch) | |
| tree | 1b921037d1310bba0efd4f92db22ba25a38d00a9 /tests/test.py | |
| parent | 7a462970852a2578c3869e581a57dd70eaa22217 (diff) | |
| download | docker-py-589e7006d59273dcc122d9d0bf2c73aa7190832d.tar.gz | |
Add support for filtering images and containers
[`filters` is a json encoded value of the filters (a map[string][string]) to process on the images list. ][1]
The tricky thing is that we must convert boolean value to string and any filter value to list to make a `map[string][string]` json format
[1]: https://docs.docker.com/reference/api/docker_remote_api_v1.14/#list-images
Diffstat (limited to 'tests/test.py')
| -rw-r--r-- | tests/test.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test.py b/tests/test.py index 984e350..727d47a 100644 --- a/tests/test.py +++ b/tests/test.py @@ -181,6 +181,19 @@ class DockerClientTest(Cleanup, unittest.TestCase): timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) + def test_images_filters(self): + try: + self.client.images(filters={'dangling': True}) + except Exception as e: + self.fail('Command should not raise exception: {0}'.format(e)) + + fake_request.assert_called_with( + url_prefix + 'images/json', + params={'filter': None, 'only_ids': 0, 'all': 0, + 'filters': '{"dangling": ["true"]}'}, + timeout=docker.client.DEFAULT_TIMEOUT_SECONDS + ) + def test_list_containers(self): try: self.client.containers(all=True) |
