From a1187ee6f3a85f8d4e68717731b7b9e2163e8f25 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Wed, 11 Nov 2020 16:47:05 -0700 Subject: Refactor to use DockerClient vs APIClient * Update tests and framework * remove tests for APIClient methods Signed-off-by: Jhon Honce --- test/apiv2/rest_api/test_rest_v2_0_0.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'test/apiv2/rest_api') 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 0ac4fde75..7192347c7 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -165,11 +165,34 @@ class TestApi(unittest.TestCase): r = requests.get(_url(ctnr("/containers/{}/logs?stdout=true"))) self.assertEqual(r.status_code, 200, r.text) - def test_post_create(self): - self.skipTest("TODO: create request body") - r = requests.post(_url("/containers/create?args=True")) - self.assertEqual(r.status_code, 200, r.text) - json.loads(r.text) + def test_post_create_compat(self): + """Create network and container then connect to network""" + net = requests.post( + PODMAN_URL + "/v1.40/networks/create", json={"Name": "TestNetwork"} + ) + self.assertEqual(net.status_code, 201, net.text) + + create = requests.post( + PODMAN_URL + "/v1.40/containers/create?name=postCreate", + json={ + "Cmd": ["date"], + "Image": "alpine:latest", + "NetworkDisabled": False, + "NetworkConfig": { + "EndpointConfig": {"TestNetwork": {"Aliases": ["test_post_create"]}} + }, + }, + ) + self.assertEqual(create.status_code, 201, create.text) + payload = json.loads(create.text) + self.assertIsNotNone(payload["Id"]) + + connect = requests.post( + PODMAN_URL + "/v1.40/networks/TestNetwork/connect", + json={"Container": payload["Id"]}, + ) + self.assertEqual(connect.status_code, 200, create.text) + self.assertEqual(connect.text, "OK\n") def test_commit(self): r = requests.post(_url(ctnr("/commit?container={}"))) -- cgit v1.2.3-54-g00ecf