summaryrefslogtreecommitdiff
path: root/test/apiv2
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-11-11 16:47:05 -0700
committerJhon Honce <jhonce@redhat.com>2020-11-12 15:13:09 -0700
commita1187ee6f3a85f8d4e68717731b7b9e2163e8f25 (patch)
tree76617b969d1f8c2069c0492f1d7c4ea117cfc9ce /test/apiv2
parenta65ecc70c21eb5eef7d7a6b70cc1f90e577bb72e (diff)
downloadpodman-a1187ee6f3a85f8d4e68717731b7b9e2163e8f25.tar.gz
podman-a1187ee6f3a85f8d4e68717731b7b9e2163e8f25.tar.bz2
podman-a1187ee6f3a85f8d4e68717731b7b9e2163e8f25.zip
Refactor to use DockerClient vs APIClient
* Update tests and framework * remove tests for APIClient methods Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'test/apiv2')
-rw-r--r--test/apiv2/rest_api/test_rest_v2_0_0.py33
1 files changed, 28 insertions, 5 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 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={}")))