Step 2: Move test folder to root
[integration/test.git] / 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 def get(url, userId, password):
11     """Helps in making GET REST calls"""
12     headers = {}
13     headers['Accept'] = 'application/xml'
14
15     # Send the GET request
16     req = requests.get(url, None, headers)
17
18     # Read the response
19     return req
20
21
22 def nonprintpost(url, userId, password, data):
23     """Helps in making POST REST calls without outputs"""
24     headers = {}
25     headers['Content-Type'] = 'application/json'
26     # headers['Accept']= 'application/xml'
27
28     resp = requests.post(url, data.encode(), headers=headers)
29
30     return resp
31
32
33 def post(url, userId, password, data):
34     """Helps in making POST REST calls"""
35     print("post request with url " + url)
36     print("post request with data " + data)
37     headers = {}
38     headers['Content-Type'] = 'application/json'
39     # headers['Accept']= 'application/xml'
40
41     resp = requests.post(url, data.encode(), headers=headers)
42
43     # print (resp.raise_for_status())
44     print(resp.headers)
45
46     return resp
47
48
49 def delete(url, userId, password):
50     """Helps in making DELET REST calls"""
51     print("delete all resources belonging to url" + url)
52     resp = requests.delete(url)  # noqa