diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-12-04 14:21:27 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-12-04 16:27:42 -0700 |
commit | 9b11fc00f1b4492ab6d80101436941d88fa5dd01 (patch) | |
tree | cafcc0352067d64a28750287910666a54901ec89 /test | |
parent | 8e83799d5898aacfddabf40fb1512c5168d0b779 (diff) | |
download | podman-9b11fc00f1b4492ab6d80101436941d88fa5dd01.tar.gz podman-9b11fc00f1b4492ab6d80101436941d88fa5dd01.tar.bz2 podman-9b11fc00f1b4492ab6d80101436941d88fa5dd01.zip |
Jira RUN-1106 Volumes handlers updates
* Add tests to verify required fields in responses
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/apiv2/rest_api/test_rest_v2_0_0.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py index d4608a5f7..3d015a896 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -423,6 +423,57 @@ class TestApi(unittest.TestCase): prune = requests.post(PODMAN_URL + "/v1.40/networks/prune") self.assertEqual(prune.status_code, 405, prune.content) + def test_volumes_compat(self): + name = "Volume_" + "".join(random.choice(string.ascii_letters) for i in range(10)) + + ls = requests.get(PODMAN_URL + "/v1.40/volumes") + self.assertEqual(ls.status_code, 200, ls.content) + + # See https://docs.docker.com/engine/api/v1.40/#operation/VolumeList + required_keys = ( + "Volumes", + "Warnings", + ) + + obj = json.loads(ls.content) + self.assertIn(type(obj), (dict,)) + for k in required_keys: + self.assertIn(k, obj) + + create = requests.post(PODMAN_URL + "/v1.40/volumes/create", json={"Name": name}) + self.assertEqual(create.status_code, 201, create.content) + + # See https://docs.docker.com/engine/api/v1.40/#operation/VolumeCreate + # and https://docs.docker.com/engine/api/v1.40/#operation/VolumeInspect + required_keys = ( + "Name", + "Driver", + "Mountpoint", + "Labels", + "Scope", + "Options", + ) + + obj = json.loads(create.content) + self.assertIn(type(obj), (dict,)) + for k in required_keys: + self.assertIn(k, obj) + self.assertEqual(obj["Name"], name) + + inspect = requests.get(PODMAN_URL + f"/v1.40/volumes/{name}") + self.assertEqual(inspect.status_code, 200, inspect.content) + + obj = json.loads(create.content) + self.assertIn(type(obj), (dict,)) + for k in required_keys: + self.assertIn(k, obj) + + rm = requests.delete(PODMAN_URL + f"/v1.40/volumes/{name}") + self.assertEqual(rm.status_code, 204, rm.content) + + prune = requests.post(PODMAN_URL + "/v1.40/volumes/prune") + self.assertEqual(prune.status_code, 200, prune.content) + if __name__ == "__main__": unittest.main() |