summaryrefslogtreecommitdiffstats
path: root/vcpe_beijing/mockserver/8004-client-python3.py
diff options
context:
space:
mode:
authorhuangzh <huangzh.bri@chinatelecom.cn>2018-11-07 11:45:38 +0800
committerhuangzh <huangzh.bri@chinatelecom.cn>2018-11-08 10:57:13 +0800
commit1ff97d639e631fe7465038d76e093bc5c1a31867 (patch)
treed3f4aa2144043930c2fee7073a22e45a9f41805b /vcpe_beijing/mockserver/8004-client-python3.py
parent4d96698b0cc2b738685482c8a8971f21b143b27e (diff)
new add s3p test scripte
Change-Id: I84b933c017ad7cee12e70da868e8dea1dd9f348b Issue-ID: INT-714 Signed-off-by: huangzh <huangzh.bri@chinatelecom.cn>
Diffstat (limited to 'vcpe_beijing/mockserver/8004-client-python3.py')
-rw-r--r--vcpe_beijing/mockserver/8004-client-python3.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/vcpe_beijing/mockserver/8004-client-python3.py b/vcpe_beijing/mockserver/8004-client-python3.py
new file mode 100644
index 0000000..35ff669
--- /dev/null
+++ b/vcpe_beijing/mockserver/8004-client-python3.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+import http.client
+import json
+
+conn = http.client.HTTPConnection("localhost:8004")
+print ("Connected.")
+
+conn.request("GET", "/v1/b45461e4b03547db8f2869d2c9f9e29e/stacks/vcpe_vfmodule_vcpevspvbrg20180628a_201807200645")
+r1 = conn.getresponse()
+print ("first GET request response:")
+print ("----------------------------------------")
+print (r1.status)
+print (r1.read().decode())
+
+header = { "Content-type": "application/json" }
+fd = open('post.json')
+to_send = json.load(fd)
+data_send = json.dumps(to_send)
+conn.request("POST","/v1/b45461e4b03547db8f2869d2c9f9e29e/stacks",data_send,header)
+r0 = conn.getresponse()
+print ("POST request response:")
+print ("----------------------------------------")
+print (r0.status)
+jdata = json.loads(r0.read())
+print(jdata)
+random_key = jdata["stack"]["id"]
+result = "/v1/b45461e4b03547db8f2869d2c9f9e29e/stacks/vcpe_vfmodule_vcpevspvbrg20180628a_201807200718/{}".format(random_key)
+
+conn.request("GET", result)
+r2 = conn.getresponse()
+print ("second GET request response:")
+print ("----------------------------------------")
+print (r2.status)
+print (r2.read().decode())
+
+conn.request("GET", result)
+r3 = conn.getresponse()
+print ("third GET request response:")
+print ("----------------------------------------")
+print (r3.status)
+print (r3.read().decode())
+
+conn.request("GET", result)
+r4 = conn.getresponse()
+print ("fourth GET request response:")
+print ("----------------------------------------")
+print (r4.status)
+print (r4.read().decode())
+
+
+
+