2 Suite Teardown Kill The Tree ${ODL_SYSTEM_IP} InCSE1 admin admin
3 Library ../../../libraries/criotdm.py
7 ${httphost} ${ODL_SYSTEM_IP}
12 ${rt_contentInstance} 4
16 [Documentation] set a suite variable ${iserver}
17 #==================================================
18 # Container Mandatory Attribute Test
19 #==================================================
20 # mandatory attribute: content
26 ${iserver} = Connect To Iotdm ${httphost} ${httpuser} ${httppass} http
27 Set Suite Variable ${iserver}
29 1.1 After Created, test whether all the mandatory attribtues are exist.
30 [Documentation] create 1 conIn test whether all the mandatory attribtues are exist
31 ${attr} = Set Variable "rn":"Container1"
32 ${r}= Create Resource ${iserver} InCSE1 ${rt_container} ${attr}
33 ${container} = Location ${r}
34 ${status_code} = Status Code ${r}
35 Should Be Equal As Integers ${status_code} 201
36 ${attr} = Set Variable "con":"102CSS","rn":"conIn1"
37 Create Resource ${iserver} InCSE1/Container1 ${rt_contentInstance} ${attr}
39 Should Contain ${text} "ri": "rn": "cs":
40 Should Contain ${text} "lt": "pi": "con":
41 Should Contain ${text} "ct": "rty":4
42 Should Not Contain S{text} "lbl" "creator" "or"
44 1.21 Missing content should return error
45 [Documentation] Missing content should return error
46 ${attr} = Set Variable
47 ${error} = Run Keyword And Expect Error * Create Resource ${iserver} InCSE1/Container1 ${rt_contentInstance}
49 Should Start with ${error} Cannot create this resource [400]
50 Should Contain ${error} CONTENT missing
51 #===========================================================
52 # ContentInstance Optional Attribute Test (Allowed)
53 #===========================================================
56 # Optional attribute: [aa,at],contentInfo, ontologyRef, label, creator
58 2.11 ContentInfo (cnf) can be added when create
59 [Documentation] ContentInfo (cnf) can be added when create
60 ${attr} = Set Variable "cnf": "1","con":"102CSS","rn":"conIn2"
61 # create conIn under Container1
62 ${r}= Create Resource ${iserver} InCSE1/Container1 ${rt_contentInstance} ${attr}
63 ${text} = Check Create and Retrieve ContentInstance ${r}
64 Should Contain ${text} cnf
66 Delete the ContenInstance 2.1
67 ${deleteRes} = Delete Resource ${iserver} InCSE1/Container1/conIn2
69 2.12 ContentInfo (cnf) cannot be updated
70 [Documentation] ContentInfo (cnf) cannot be updated
71 ${attr} = Set Variable "cnf": "1"
72 ${error} = Cannot Update ContentInstance Error ${attr}
73 Should Contain ${error} Not permitted to update content
75 2.21 OntologyRef (or) can be added when create
76 [Documentation] OntologyRef (or) can be added when create
77 ${attr} = Set Variable "or": "http://cisco.com","con":"102CSS","rn":"conIn2"
78 # create conIn under Container1
79 ${r}= Create Resource ${iserver} InCSE1/Container1 ${rt_contentInstance} ${attr}
80 ${text} = Check Create and Retrieve ContentInstance ${r}
81 Should Contain ${text} or
83 Delete the ContenInstance 2.2
84 ${deleteRes} = Delete Resource ${iserver} InCSE1/Container1/conIn2
86 2.22 OntologyRef (or) cannot be updated
87 [Documentation] OntologyRef (or) cannot be updated
88 ${attr} = Set Variable "or": "1"
89 ${error} = Cannot Update ContentInstance Error ${attr}
90 Should Contain ${error} Not permitted to update content
92 2.31 labels[single] can be added when create
93 [Documentation] create conIn under Container1, labels[single] can be added when create
94 ${attr} = Set Variable "lbl":["ds"],"con":"102CSS","rn":"conIn2"
95 ${r}= Create Resource ${iserver} InCSE1/Container1 ${rt_contentInstance} ${attr}
96 ${text} = Check Create and Retrieve ContentInstance ${r}
97 Should Contain ${text} lbl
99 Delete the ContenInstance 2.31
100 ${deleteRes} = Delete Resource ${iserver} InCSE1/Container1/conIn2
102 2.32 labels (single) cannot be updated
103 [Documentation] update labels then expect error
104 ${attr} = Set Variable "lbl":["1"]
105 ${error} = Cannot Update ContentInstance Error ${attr}
106 Should Contain ${error} Not permitted to update content
108 2.33 labels (multiple) can be added when create
109 [Documentation] labels (multiple) can be added when create
110 ${attr} = Set Variable "lbl":["http://cisco.com","dsds"],"con":"102CSS","rn":"conIn2"
111 # create conIn under Container1
112 ${r}= Create Resource ${iserver} InCSE1/Container1 ${rt_contentInstance} ${attr}
113 ${text} = Check Create and Retrieve ContentInstance ${r}
114 Should Contain ${text} lbl
116 Delete the ContenInstance 2.33
117 ${deleteRes} = Delete Resource ${iserver} InCSE1/Container1/conIn2
119 2.34 labels (multiple) cannot be updated
120 [Documentation] labels (multiple) cannot be updated
121 ${attr} = Set Variable "lbl":["1"]
122 ${error} = Cannot Update ContentInstance Error ${attr}
123 Should Contain ${error} Not permitted to update content
124 #=================================================================
125 # contentInstance Disturbing Attribute Test, Not Allowed Update
126 #=================================================================
127 # using non-valid attribtue to create then expext error
129 3.11 Mulitiple labels should return error
130 [Documentation] Mulitiple labels should return error
131 ${attr} = Set Variable "con": "1", "lbl":["label1"],"lbl":["label2"]
132 ${error} = Cannot Craete ContentInstance Error ${attr}
133 Should Contain ${error} Duplicate lbl
135 3.12 Multiple creator should return error
136 [Documentation] Multiple creator should return error
137 ${attr} = Set Variable "con": "1", "cr":null, "cr":null
138 ${error} = Cannot Craete ContentInstance Error ${attr}
139 Should Contain ${error} Duplicate cr
141 3.13 Multiple contentInfo should return error
142 [Documentation] Multiple contentInfo should return error
143 ${attr} = Set Variable "con": "1", "cnf":"1","cnf":"2"
144 ${error} = Cannot Craete ContentInstance Error ${attr}
145 Should Contain ${error} Duplicate cnf
147 3.14 Multiple ontologyRef should return error
148 [Documentation] Multiple ontologyRef should return error
149 ${attr} = Set Variable "con": "1", "or":"http://cisco.com","or":"http://google.com"
150 ${error} = Cannot Craete ContentInstance Error ${attr}
151 Should Contain ${error} Duplicate or
153 3.15 Mulptiple content should return error
154 [Documentation] Mulptiple content should return error
155 ${attr} = Set Variable "con": "1", "con":"2313"
156 ${error} = Cannot Craete ContentInstance Error ${attr}
157 Should Contain ${error} Duplicate con
158 #----------------All attributes cannot be updated----------
160 3.21 resourceType cannot be updated.
161 [Documentation] update resourceType and expect error
162 ${attr} = Set Variable "rt": 3
163 ${error} = Cannot Update ContentInstance Error ${attr}
164 Should Contain ${error} Not permitted to update content
166 3.22 resourceId cannot be updated.
167 [Documentation] update resourceId and expect error
168 ${attr} = Set Variable "ri": "e4e43"
169 ${error} = Cannot Update ContentInstance Error ${attr}
170 Should Contain ${error} Not permitted to update content
172 3.23 resourceName cannot be updated.
173 [Documentation] update resourceName and expect error
174 ${attr} = Set Variable "rn": "4343"
175 ${error} = Cannot Update ContentInstance Error ${attr}
176 Should Contain ${error} Not permitted to update content
178 3.24 parentId cannot be updated.
179 [Documentation] update parentID and expect error
180 ${attr} = Set Variable "pi": "InCSE2/ERE"
181 ${error} = Cannot Update ContentInstance Error ${attr}
182 Should Contain ${error} Not permitted to update content
184 3.25 cretionTime cannot be updated.
185 [Documentation] update createTime and expect error
186 ${attr} = Set Variable "ct": "343434T34322"
187 ${error} = Cannot Update ContentInstance Error ${attr}
188 Should Contain ${error} Not permitted to update content
190 3.26 lastmodifiedTime cannot be updated.
191 [Documentation] update lt then expect error
192 ${attr} = Set Variable "lt": "434343T23232"
193 ${error} = Cannot Update ContentInstance Error ${attr}
194 Should Contain ${error} Not permitted to update content
196 3.27 contentSize cannot be updated.
197 [Documentation] update contentSize then expect error
198 ${attr} = Set Variable "cs": 232
199 ${error} = Cannot Update ContentInstance Error ${attr}
200 Should Contain ${error} Not permitted to update content
202 3.28 content cannot be updated
203 [Documentation] update content then expect error
204 ${attr} = Set Variable "con": "1"
205 ${error} = Cannot Update ContentInstance Error ${attr}
206 Should Contain ${error} Not permitted to update content
209 [Documentation] Set mni to 1 when creating a container, then continue creating <cin> "get latest" should always return the last created <cin>'s "con" value.
210 ${attr} = Set Variable "mni":1,"rn":"Container2"
211 ${r}= Create Resource ${iserver} InCSE1 ${rt_container} ${attr}
212 ${container} = Location ${r}
213 ${random} = Evaluate random.randint(0,50) modules=random
214 ${attr} = Set Variable "cnf": "1","or": "http://hey/you","con":"${random}"
215 Create Resource ${iserver} ${container} ${rt_contentInstance} ${attr}
216 ${latestCon} = Get Latest ${container}
217 Should Be Equal As Strings ${random} ${latestCon}
219 4.12 GetLatest Loop 50 times Test
220 [Documentation] Just like 4.11, but do 50 times.
221 ${attr} = Set Variable "mni":1,"rn":"Container3"
222 ${r}= Create Resource ${iserver} InCSE1 ${rt_container} ${attr}
223 ${container} = Location ${r}
224 : FOR ${INDEX} IN RANGE 1 100
225 \ Latest Con Test ${container}
227 Delete the test Container1
228 [Documentation] Delete the test Container1
229 ${deleteRes} = Delete Resource ${iserver} InCSE1/Container1
232 Cannot Update ContentInstance Error
234 ${error} = Run Keyword And Expect Error * update Resource ${iserver} InCSE1/Container1/conIn1 ${rt_contentInstance}
236 Should Start with ${error} Cannot update this resource [405]
239 Cannot Craete ContentInstance Error
241 ${error} = Run Keyword And Expect Error * create Resource ${iserver} InCSE1/Container1/conIn1 ${rt_contentInstance}
243 Should Start with ${error} Cannot create this resource [400]
246 Check Create and Retrieve ContentInstance
248 ${con} = Location ${r}
249 ${status_code} = Status Code ${r}
250 Should Be Equal As Integers ${status_code} 201
251 ${rr} = Retrieve Resource ${iserver} ${con}
256 [Arguments] ${resourceURI}
257 ${latest} = Retrieve Resource ${iserver} ${resourceURI}/latest
258 [Return] ${latest.json()['m2m:cin']['con']}
261 [Arguments] ${resourceURI}
262 ${random} = Evaluate random.randint(0,50) modules=random
263 ${attr} = Set Variable "cnf": "1","or": "http://hey/you","con":"${random}"
264 Create Resource ${iserver} ${resourceURI} ${rt_contentInstance} ${attr}
265 ${latestCon} = Get Latest ${resourceURI}
266 Should Be Equal As Strings ${random} ${latestCon}