Merge "Initial isolation test integrated with robot framework Usage: pybot -v LEADER...
[integration/test.git] / test / csit / libraries / SettingsLibrary.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 from string import Template
7
8 # helps in taking the hostname entered by the user
9 #global hostname 
10 #global port
11
12 #def setHostname(host):
13 #     hostname=host
14
15 #def getServer():
16 #    return hostname +":"+"8080"
17
18 #Cars resource URL for GET
19 def getCarsUrl(hostname,port):
20
21     return "http://"+hostname+":"+port+"/restconf/config/car:cars"
22
23 #People resouce URL for GET
24 def getPersonsUrl(hostname,port):
25
26     return "http://"+hostname+":"+port+"/restconf/config/people:people"
27
28 #GET cars persons mapping resource URL
29 def getCarPersonUrl(hostname,port):
30
31     return "http://"+hostname+":"+port+"/restconf/config/car-people:car-people"
32
33 #POST or DELETE URL
34 def getAddCarUrl(hostname,port):
35     return "http://"+hostname+":"+port+"/restconf/config"
36 #POST or DELETE URL
37 def getAddPersonUrl(hostname,port):
38     return "http://"+hostname+":"+port+"/restconf/config"
39
40 #POST URL -using rpc
41 def getAddPersonRpcUrl(hostname,port):
42     return "http://"+hostname+":"+port+"/restconf/operations/people:add-person"
43
44 #POST URL for car person mapping
45 def getAddCarPersonUrl(hostname,port):
46    return "http://"+hostname+":"+port+"/restconf/config"
47 #POST URL for buy car rpc
48 def getBuyCarRpcUrl(hostname,port):
49     return "http://"+hostname+":"+port+"/restconf/operations/car-purchase:buy-car"
50
51
52 # Template for Car resource payload
53 add_car_payload_template = Template( '{\"car:cars\":{'
54     '\"car-entry\": ['
55         '{'
56             '\"id\": \"$id\",'
57             '\"category\": \"$category\",'
58             '\"model\": \"$model\",'
59             '\"manufacturer\": \"$manufacturer\",'
60             '\"year\": \"$year\"'
61         '}'
62     ']'
63 '}'
64 '}')
65
66 # Template for Person resource payload
67 add_person_payload_template =  Template( '{\"people:people":{'
68     '\"person\": ['
69         '{'
70             '\"id\": \"$personId\",'
71             '\"gender\": \"$gender\",'
72             '\"age\": \"$age\",'
73             '\"address\": \"$address\",'
74             '\"contactNo\":\"$contactNo\"'
75         '}'
76             ']'
77      '}}')
78
79 # Template for Car Person mapping  payload
80 add_car_person_template = Template('{\"car-people:car-people\":{'
81     '\"car-person\": ['
82         '{'
83            ' \"car-id\": \"$Id\",'
84             '\"person-id\": \"$personId\"'
85         '}'
86     ']'
87 '}'
88 '}')
89
90 # Template for adding person using RPC
91 add_person_rpc_payload_template = Template ( '{'
92                                                  '\"input\":'
93                                                      '{'
94                                                          '\"people:id\" : \"$personId\",'
95                                                          '\"people:gender\":\"$gender\",'
96                                                          '\"people:address\" : \"$address\",'
97                                                          '\"people:contactNo\":\"$contactNo\",'
98                                                          '\"people:age\":\"$age\"'
99                                                      '}'
100                                              '}')
101
102 # Template for buing car rpc
103 buy_car_rpc_template = Template ( '{'
104     '\"input\" :'
105         '{'
106             '\"car-purchase:person\" : \"/people:people/people:person[people:id=\'$personId\']\",'
107             '\"car-purchase:person-id\" : \"$personId\",'
108             '\"car-purchase:car-id\" : \"$carId\"'
109         '}'
110 '}')
111
112
113