Merge "Fix pep8 violations in crud"
[integration/test.git] / test / tools / odl-mdsal-clustering-tests / clustering-functional-test / util.py
1 __author__ = "Basheeruddin Ahmed"
2 __copyright__ = "Copyright(c) 2014, Cisco Systems, Inc."
3 __license__ = "New-style BSD"
4 __email__ = "syedbahm@cisco.com"
5
6
7 import requests
8
9 #
10 #Helps in making GET REST calls
11 #
12
13 def get(url, userId, password):
14
15     headers = {}
16     headers['Accept']= 'application/xml'
17
18     # Send the GET request
19     req = requests.get(url, None, headers)
20
21     # Read the response
22     return req
23
24 #
25 #Helps in making POST REST calls without outputs
26 #
27 def nonprintpost(url, userId, password,data):
28
29     headers = {}
30     headers['Content-Type'] = 'application/json'
31     #headers['Accept']= 'application/xml'
32
33     resp = requests.post(url,data.encode(),headers=headers)
34
35
36     return resp
37
38 #
39 #Helps in making POST REST calls
40 #
41 def post(url, userId, password,data):
42     print("post request with url "+url)
43     print("post request with data "+data)
44     headers = {}
45     headers['Content-Type'] = 'application/json'
46     #headers['Accept']= 'application/xml'
47
48     resp = requests.post(url,data.encode(),headers=headers)
49
50     #print (resp.raise_for_status())
51     print (resp.headers)
52
53     return resp
54
55 #
56 #Helps in making DELET REST calls
57 #
58 def delete(url,userId,password):
59     print("delete all resources belonging to url"+url)
60     resp=requests.delete(url)
61
62