summaryrefslogtreecommitdiffstats
path: root/proxy/code/scripts/test-consumerapi.py
diff options
context:
space:
mode:
authorjesus m. rodriguez <jesusr@redhat.com>2009-08-27 15:37:47 -0400
committerjesus m. rodriguez <jesusr@redhat.com>2009-08-27 15:44:21 -0400
commit576fb0e9f68b188183ca4931d3db05bd0965daf3 (patch)
tree0c3e43ba1f16d89a7481c4b15ec62ca6df241c77 /proxy/code/scripts/test-consumerapi.py
parentd9789aca9afed12bf73cdb4311a804c7cffc5fe4 (diff)
downloadcandlepin-576fb0e9f68b188183ca4931d3db05bd0965daf3.tar.gz
candlepin-576fb0e9f68b188183ca4931d3db05bd0965daf3.tar.xz
candlepin-576fb0e9f68b188183ca4931d3db05bd0965daf3.zip
consumer api work (not done yet)
Diffstat (limited to 'proxy/code/scripts/test-consumerapi.py')
-rwxr-xr-xproxy/code/scripts/test-consumerapi.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/proxy/code/scripts/test-consumerapi.py b/proxy/code/scripts/test-consumerapi.py
index f7f16ec..123f962 100755
--- a/proxy/code/scripts/test-consumerapi.py
+++ b/proxy/code/scripts/test-consumerapi.py
@@ -2,14 +2,37 @@
import httplib, urllib
import sys
+import simplejson as json
+
+# POST new user
+print("create consumer")
+#info = {"parent":"","type":"system","metadata":{"arch":"i386","cpu":"intel"}}
+info = {"parent":"","type":"system", "metadata":{"entry":[{"key":"arch","value":"i386"},{"key":"cpu","value":"Intel"}]}}
+params = {"owneruuid":"","info":info}
+headers = {"Content-type":"application/json",
+ "Accept": "application/json"}
+conn = httplib.HTTPConnection("localhost", 8080)
+conn.request("POST", '/candlepin/consumer/', json.dumps(params), headers)
+response = conn.getresponse()
+print("Status: %d Response: %s" % (response.status, response.reason))
+rsp = response.read()
+print("created consumer: %s" % rsp)
+conn.close()
# GET list of consumers
response = urllib.urlopen('http://localhost:8080/candlepin/consumer/')
rsp = response.read()
-print("list of users: %s" % rsp)
+print("list of consumers: %s" % rsp)
# GET candlepin user
response = urllib.urlopen('http://localhost:8080/candlepin/consumer/candlepin')
rsp = response.read()
print("get: %s" % rsp)
+# GET candlepin user
+response = urllib.urlopen('http://localhost:8080/candlepin/consumer/info')
+rsp = response.read()
+print("get info: %s" % rsp)
+
+{
+}