Tidy new and updated test suites.
[integration/test.git] / csit / suites / iotdm / basic / 050_ContainerAttributeTest.robot
1 *** Settings ***
2 Suite Teardown    Kill The Tree    ${ODL_SYSTEM_IP}    InCSE1    admin    admin
3 Library           ../../../libraries/criotdm.py
4 Library           Collections
5
6 *** Variables ***
7 ${httphost}       ${ODL_SYSTEM_IP}
8 ${httpuser}       admin
9 ${httppass}       admin
10 ${rt_ae}          2
11 ${rt_container}    3
12 ${rt_contentInstance}    4
13
14 *** Test Cases ***
15 Set Suite Variable
16     [Documentation]    set a suite variable ${iserver}
17     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
18     Set Suite Variable    ${iserver}
19     #==================================================
20     #    Container Mandatory Attribute Test
21     #==================================================
22     # For Creation, there are no mandatory input attribute
23
24 1.1 After Created, test whether all the mandatory attribtues are exist.
25     [Documentation]    After Created, test whether all the mandatory attribtues are exist.
26     ${attr} =    Set Variable    "rn":"Container1"
27     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
28     ${container} =    Location    ${r}
29     ${status_code} =    Status Code    ${r}
30     Should Be Equal As Integers    ${status_code}    201
31     ${text} =    Text    ${r}
32     Should Contain    ${text}    "ri":    "rn":    "cni"
33     Should Contain    ${text}    "lt":    "pi":    "st":
34     Should Contain    ${text}    "ct":    "ty":3    "cbs"
35     Should Not Contain    S{text}    "lbl"    "creator"    "or"
36     #==================================================
37     #    Container Optional Attribute Test (Allowed)
38     #==================================================
39     #    create--> delete
40     #    update(create)--> update(modified)-->update (delete)
41
42 2.11 maxNumberofInstance (mni) can be added when create
43     [Documentation]    maxNumberofInstance (mni) can be added when create
44     ${attr} =    Set Variable    "mni":3,"rn":"Container2"
45     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
46     ${text} =    Check Response and Retrieve Resource    ${r}
47     Should Contain    ${text}    "mni"
48
49 Delete the Container2-2.1
50     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
51
52 2.12 maxNumberofInstance (mni) can be added through update (0-1)
53     [Documentation]    maxNumberofInstance (mni) can be added through update (0-1)
54     ${attr} =    Set Variable    "mni":3
55     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
56     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
57     Should Contain    ${text}    "mni"
58
59 2.13 maxNumberofInstance (mni) can be modified through update (1-1)
60     [Documentation]    maxNumberofInstance (mni) can be modified through update (1-1)
61     ${attr} =    Set Variable    "mni":5
62     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
63     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
64     Should Contain    ${text}    "mni":5
65     Should Not Contain    ${text}    "mni":3
66
67 2.14 if set to null, maxnumberofInstance (mni) can be deleted through delete(1-0)
68     [Documentation]    if set to null, maxnumberofInstance (mni) can be deleted through delete(1-0)
69     ${attr} =    Set Variable    "mni":null
70     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
71     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
72     Should Not Contain    ${text}    "mni"
73
74 2.21 maxByteSize (mbs) can be added when create
75     [Documentation]    maxByteSize (mbs) can be added when create
76     ${attr} =    Set Variable    "mbs":20,"rn":"Container2"
77     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
78     ${text} =    Check Response and Retrieve Resource    ${r}
79     Should Contain    ${text}    "mbs"
80
81 Delete the Container2-2.2
82     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
83
84 2.22 maxByteSize (mbs) can be added through update (0-1)
85     [Documentation]    maxByteSize (mbs) can be added through update (0-1)
86     ${attr} =    Set Variable    "mbs":20
87     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
88     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
89     Should Contain    ${text}    "mbs"
90
91 2.23 maxByteSize (mbs) can be modified through update (1-1)
92     [Documentation]    maxByteSize (mbs) can be modified through update (1-1)
93     ${attr} =    Set Variable    "mbs":25
94     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
95     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
96     Should Contain    ${text}    "mbs":25
97     Should Not Contain    ${text}    "mbs":20
98
99 2.24 if set to null, maxByteSize (mbs) can be deleted through delete(1-0)
100     [Documentation]    if set to null, maxByteSize (mbs) can be deleted through delete(1-0)
101     ${attr} =    Set Variable    "mbs":null
102     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
103     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
104     Should Not Contain    ${text}    "mbs"
105
106 2.31 ontologyRef(or) can be added when create
107     [Documentation]    ontologyRef(or) can be added when create
108     ${attr} =    Set Variable    "or":"http://cisco.com","rn":"Container2"
109     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
110     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container2
111     Should Contain    ${text}    "or"
112
113 Delete the Container2-2.3
114     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
115
116 2.32 ontologyRef(or) can be added through update (0-1)
117     [Documentation]    ontologyRef(or) can be added through update (0-1)
118     ${attr} =    Set Variable    "or":"http://cisco.com"
119     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
120     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
121     Should Contain    ${text}    "or"
122
123 2.33 ontologyRef(or) can be modified through update (1-1)
124     [Documentation]    ontologyRef(or) can be modified through update (1-1)
125     ${attr} =    Set Variable    "or":"http://iotdm.com"
126     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
127     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
128     Should Contain    ${text}    "or":"http://iotdm.com"
129     Should Not Contain    ${text}    "or":"http://cisco.com"
130
131 2.34 if set to null, ontologyRef(or) can be deleted through delete(1-0)
132     [Documentation]    if set to null, ontologyRef(or) can be deleted through delete(1-0)
133     ${attr} =    Set Variable    "or":null
134     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
135     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
136     Should Not Contain    ${text}    "or"
137
138 2.41 labels can be created through update (0-1)
139     [Documentation]    labels can be created through update (0-1)
140     ${attr} =    Set Variable    "lbl":["label1"]
141     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
142     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
143     Should Contain    ${text}    lbl    label1
144
145 2.42 labels can be modified (1-1)
146     [Documentation]    labels can be modified (1-1)
147     ${attr} =    Set Variable    "lbl":["label2"]
148     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
149     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
150     Should Not Contain    ${text}    label1
151     Should Contain    ${text}    lbl    label2
152
153 2.43 if set to null, labels should be deleted(1-0)
154     [Documentation]    if set to null, labels should be deleted(1-0)
155     ${attr} =    Set Variable    "lbl":null
156     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
157     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
158     Should Not Contain    ${text}    lbl    label1    label2
159
160 2.44 labels can be created through update (0-n)
161     [Documentation]    labels can be created through update (0-n)
162     ${attr} =    Set Variable    "lbl":["label3","label4","label5"]
163     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
164     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
165     Should Contain    ${text}    lbl    label3    label4
166     Should Contain    ${text}    label5
167
168 2.45 labels can be modified (n-n)(across)
169     [Documentation]    labels can be modified (n-n)(across)
170     ${attr} =    Set Variable    "lbl":["label4","label5","label6"]
171     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
172     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
173     Should Not Contain    ${text}    label1    label2    label3
174     Should Contain    ${text}    lbl    label4    label5
175     Should Contain    ${text}    label6
176
177 2.46 labels can be modified (n-n)(not across)
178     [Documentation]    labels can be modified (n-n)(not across)
179     ${attr} =    Set Variable    "lbl":["label7","label8","label9"]
180     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
181     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
182     Should Not Contain    ${text}    label1    label2    label3
183     Should Not Contain    ${text}    label6    label4    label5
184     Should Contain    ${text}    lbl    label7    label8
185     Should Contain    ${text}    label9
186
187 2.47 if set to null, labels should be deleted(n-0)
188     [Documentation]    if set to null, labels should be deleted(n-0)
189     ${attr} =    Set Variable    "lbl":null
190     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
191     ${text} =    Check Response and Retrieve Resource For Update    ${r}    InCSE1/Container1
192     Should Not Contain    ${text}    label1    label2    label3
193     Should Not Contain    ${text}    label6    label4    label5
194     Should Not Contain    ${text}    label7    label8    label9
195     Should Not Contain    ${text}    lbl
196     #======================================================
197     #    Container Disturbing Attribute Test, Not Allowed Update
198     #======================================================
199     # using non-valid attribtue to create then expext error
200
201 3.11 Mulitiple maxNrofInstance should return error
202     [Documentation]    Mulitiple maxNrofInstance should return error
203     ${attr} =    Set Variable    "mni":33,"mni":33
204     ${error} =    Cannot Create Container Error    ${attr}
205     Should Contain    ${error}    Duplicate key    mni
206
207 3.12 Mulitiple maxByteSize should return error
208     [Documentation]    Mulitiple maxByteSize should return error
209     ${attr} =    Set Variable    "mbs":44,"mbs":44
210     ${error} =    Cannot Create Container Error    ${attr}
211     Should Contain    ${error}    Duplicate key    mbs
212
213 3.13 Multiple creator should return error
214     [Documentation]    Multiple creator should return error
215     ${attr} =    Set Variable    "cr":null,"cr":null
216     ${error} =    Cannot Create Container Error    ${attr}
217     Should Contain    ${error}    Duplicate key    cr
218
219 3.14 Multiple ontologyRef should return error
220     [Documentation]    Multiple ontologyRef should return error
221     ${attr} =    Set Variable    "or":"http://cisco.com","or":"http://cisco.com"
222     ${error} =    Cannot Create Container Error    ${attr}
223     Should Contain    ${error}    Duplicate key    or
224
225 3.14 Multiple label attribute should return error(multiple array)
226     [Documentation]    Multiple label attribute should return error(multiple array)
227     ${attr} =    Set Variable    "lbl":["ODL1"], "lbl":["dsdsd"]
228     ${error} =    Cannot Create Container Error    ${attr}
229     Should Contain    ${error}    Duplicate key    lbl
230     #    3.2 Input of Integer using String should return error    [Should checked by wenxin]
231     #------------------------------------------------------
232     # using non-valid attribute to update then expect error
233
234 3.31 resourceType cannot be update.
235     [Documentation]    when update resourceType, expect error
236     ${attr} =    Set Variable    "ty":2
237     ${error} =    Cannot Update Container Error    ${attr}
238     Should Contain    ${error}    error
239
240 3.32 resoureceID cannot be update.
241     [Documentation]    update resoureceID then expect error
242     ${attr} =    Set Variable    "ri":"aaa"
243     ${error} =    Cannot Update Container Error    ${attr}
244     Should Contain    ${error}    error    ri
245
246 3.33 resouceNme cannot be update.(write once)
247     [Documentation]    update resourceName and expect error
248     ${attr} =    Set Variable    "rn":"aaa"
249     ${error} =    Cannot Update Container Error    ${attr}
250     Should Contain    ${error}    error    rn
251
252 3.34 parentID cannot be update.
253     [Documentation]    update parentID and expect error
254     ${attr} =    Set Variable    "pi":"aaa"
255     ${error} =    Cannot Update Container Error    ${attr}
256     Should Contain    ${error}    error    pi
257
258 3.35 createTime cannot be update.
259     [Documentation]    update createTime and expect error
260     ${attr} =    Set Variable    "ct":"aaa"
261     ${error} =    Cannot Update Container Error    ${attr}
262     Should Contain    ${error}    error    ct
263
264 3.36 curerntByteSize cannot be update --- Special, cannot be modified by the user
265     [Documentation]    update currentByteSize and expect error
266     ${attr} =    Set Variable    "cbs":123
267     ${error} =    Cannot Update Container Error    ${attr}
268     Should Contain    ${error}    error    api
269
270 3.37 currentNrofInstance cannot be updated --- Special, cannot be modified by the user
271     [Documentation]    update cni and expect error
272     ${attr} =    Set Variable    "cni":3
273     ${error} =    Cannot Update Container Error    ${attr}
274     Should Contain    ${error}    error    aei
275
276 3.38 LastMoifiedTime --- Special, cannot be modified by the user
277     [Documentation]    update lt and expect error
278     ${attr} =    Set Variable    "lt":"aaa"
279     ${error} =    Cannot Update Container Error    ${attr}
280     Should Contain    ${error}    error    lt
281
282 3.39 stateTag --- Special, cannot be modified by the user
283     [Documentation]    update st and expect error
284     ${attr} =    Set Variable    "st":3
285     ${error} =    Cannot Update Container Error    ${attr}
286     Should Contain    ${error}    error    st
287
288 3.310 creator -- cannot be modified
289     [Documentation]    update cr and expect error
290     ${attr} =    Set Variable    "cr":null
291     ${error} =    Cannot Update Container Error    ${attr}
292     Should Contain    ${error}    error    cr
293
294 3.41 Using AE's M attribute to create
295     [Documentation]    use AE attribtue to create Container then expect error
296     ${attr} =    Set Variable    "api":"ODL","aei":"ODL"
297     ${error} =    Cannot Update Container Error    ${attr}
298     Should Contain    ${error}    CONTENT(pc)
299
300 3.42 Using ContentInstance's M attribute to create
301     [Documentation]    use contentInstance attribtue to create Container then expect error
302     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
303     ${error} =    Cannot Update Container Error    ${attr}
304     Should Contain    ${error}    CONTENT(pc)
305     #==================================================
306     #    Functional Attribute Test
307     #==================================================
308     # 1. lastModifiedTime
309     # 2. parentID
310     # 3. stateTag
311     # 4. currentNrOfInstances
312     # 5. currentByteSize
313     # 6. maxNrOfInstances
314     # 7. maxByteSize
315     # 8. creator
316     # 9. contentSize
317     # 10. childresource
318     #-------------- 1.    lastModifiedTime    -----------
319
320 4.11 if updated seccessfully, lastModifiedTime must be modified.
321     [Documentation]    if updated seccessfully, lastModifiedTime must be modified.
322     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container1
323     ${lt1} =    LastModifiedTime    ${oldr}
324     ${attr} =    Set Variable    "lbl":["aaa"]
325     Sleep    1s
326     # We know Beryllium is going to be get rid of all sleep.
327     # But as lastModifiedTime has precision in seconds,
328     # we need to wait 1 second to see different value on update.
329     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
330     ${lt2} =    LastModifiedTime    ${r}
331     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${lt2}
332
333 4.12 childResources create , parent's lastmodifiedTime update
334     [Documentation]    childResources create , parent's lastmodifiedTime update
335     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container1
336     ${lt1} =    LastModifiedTime    ${oldr}
337     Sleep    1s
338     # We know Beryllium is going to be get rid of all sleep.
339     # But as lastModifiedTime has precision in seconds,
340     # we need to wait 1 second to see different value on update.
341     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","rn":"conIn1"
342     ${r} =    Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}    ${attr}
343     ${lt2} =    LastModifiedTime    ${r}
344     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${lt2}
345     #-------------- 2 parentID ------------
346
347 4.21 Check parentID(cse-container)
348     [Documentation]    parentID should be InCSE1
349     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1
350     ${CSEID} =    Set Variable    ${oldr.json()['m2m:cb']['ri']}
351     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container1
352     Should Be Equal    /InCSE1/${oldr.json()['m2m:cb']['ri']}    ${r.json()['m2m:cnt']['pi']}
353
354 4.22 Check parentID(cse-container-container)
355     [Documentation]    parentID should be correct
356     # CSE
357     #    |--Contianer1
358     #    |--Container2
359     ${attr} =    Set Variable    "rn":"Container2"
360     ${r}=    Create Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
361     ${status_code} =    Status Code    ${r}
362     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container1
363     ${CSEID} =    Set Variable    ${oldr.json()['m2m:cnt']['ri']}
364     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container1/Container2
365     Should Be Equal    /InCSE1/${oldr.json()['m2m:cnt']['ri']}    ${r.json()['m2m:cnt']['pi']}
366
367 4.23 Check parentID(cse-AE-container)
368     [Documentation]    parentID should be correct
369     # CSE
370     #    |--AE1
371     #    |--Container2
372     ${attr} =    Set Variable    "api":"ODL","apn":"ODL","rr":true,"rn":"AE1"
373     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}
374     ${attr} =    Set Variable    "rn":"Container2"
375     ${r}=    Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    ${attr}
376     ${status_code} =    Status Code    ${r}
377     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/AE1
378     ${CSEID} =    Set Variable    ${oldr.json()['m2m:ae']['ri']}
379     ${r} =    Retrieve Resource    ${iserver}    InCSE1/AE1/Container2
380     Should Be Equal    /InCSE1/${oldr.json()['m2m:ae']['ri']}    ${r.json()['m2m:cnt']['pi']}
381
382 4.24 Check parentID(cse-AE-container-container)
383     [Documentation]    parentID should be correct
384     # CSE
385     #    |--AE1
386     #    |--Container2
387     #    |--- Container3
388     ${attr} =    Set Variable    "rn":"Container3"
389     ${r}=    Create Resource    ${iserver}    InCSE1/AE1/Container2    ${rt_container}    ${attr}
390     ${status_code} =    Status Code    ${r}
391     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/AE1/Container2
392     ${CSEID} =    Set Variable    ${oldr.json()['m2m:cnt']['ri']}
393     ${r} =    Retrieve Resource    ${iserver}    InCSE1/AE1/Container2/Container3
394     Should Be Equal    /InCSE1/${oldr.json()['m2m:cnt']['ri']}    ${r.json()['m2m:cnt']['pi']}
395
396 Delete the test AE-4.2
397     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/AE1
398     #--------------3. stateTag------------
399
400 4.31 stateTag (when create, check if 0)
401     [Documentation]    when create, st should be 0
402     # CSE
403     #    |--Container2
404     ${attr} =    Set Variable    "rn":"Container2"
405     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
406     ${container} =    Location    ${r}
407     ${status_code} =    Status Code    ${r}
408     ${oldr} =    Retrieve Resource    ${iserver}    ${container}
409     ${st} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
410     Should Be Equal As Integers    0    ${st}
411     # 4.32 stateTag (when update expirationTime)
412     # 4.33 stateTag (when update accessControlPolicyIDs)
413
414 4.34 stateTag (when update labels) + lastModifiedTime
415     [Documentation]    st and lt should be changed
416     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
417     ${oldst} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
418     ${attr} =    Set Variable    "lbl":["label1"]
419     Sleep    1s
420     # We know Beryllium is going to be get rid of all sleep.
421     # But as lastModifiedTime has precision in seconds,
422     # we need to wait 1 second to see different value on update.
423     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
424     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
425     Should Be Equal As Integers    ${oldst+1}    ${r.json()['m2m:cnt']['st']}
426     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${r.json()['m2m:cnt']['lt']}
427     # 4.35 stateTag (when update announceTo)
428     # 4.36 stateTag (when update announceAttribute)
429
430 4.37 stateTag (when update MaxNrOfInstances) + lastModifiedTime
431     [Documentation]    st and lt should be changed
432     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
433     ${oldst} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
434     ${attr} =    Set Variable    "mni":5
435     Sleep    1s
436     # We know Beryllium is going to be get rid of all sleep.
437     # But as lastModifiedTime has precision in seconds,
438     # we need to wait 1 second to see different value on update.
439     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
440     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
441     Should Be Equal As Integers    ${oldst+1}    ${r.json()['m2m:cnt']['st']}
442     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${r.json()['m2m:cnt']['lt']}
443
444 4.38 stateTag (when update MaxByteSize) + lastModifiedTime
445     [Documentation]    st and lt should be changed
446     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
447     ${oldst} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
448     ${attr} =    Set Variable    "mbs":30
449     Sleep    1s
450     # We know Beryllium is going to be get rid of all sleep.
451     # But as lastModifiedTime has precision in seconds,
452     # we need to wait 1 second to see different value on update.
453     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
454     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
455     Should Be Equal As Integers    ${oldst+1}    ${r.json()['m2m:cnt']['st']}
456     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${r.json()['m2m:cnt']['lt']}
457     # 4.39 stateTag (when update maxInstanceAge)
458     # 4.310 stateTag (when update locationID)
459
460 4.311 stateTag (when update ontologyRef) + lastModifiedTime
461     [Documentation]    st and lt should be changed
462     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
463     ${oldst} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
464     ${attr} =    Set Variable    "or":"http://google.com"
465     Sleep    1s
466     # We know Beryllium is going to be get rid of all sleep.
467     # But as lastModifiedTime has precision in seconds,
468     # we need to wait 1 second to see different value on update.
469     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
470     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
471     Should Be Equal As Integers    ${oldst+1}    ${r.json()['m2m:cnt']['st']}
472     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${r.json()['m2m:cnt']['lt']}
473
474 4.312 when create child container, stateTag will not increase + lastModifiedTime should change
475     [Documentation]    when create child container, stateTag will not increase + lastModifiedTime should not change
476     # CSE
477     #    |--Contianer2
478     #    |--Container3
479     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
480     ${oldst} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
481     ${attr} =    Set Variable    "lbl":["label1"],"rn":"Container3"
482     Sleep    2s
483     # We know Beryllium is going to be get rid of all sleep.
484     # But as lastModifiedTime has precision in seconds,
485     # we need to wait 1 second to see different value on update.
486     Create Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
487     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
488     Should Be Equal As Integers    ${oldst}    ${r.json()['m2m:cnt']['st']}
489     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${r.json()['m2m:cnt']['lt']}
490
491 4.313 * when create child contentInsntance, state should increase + lastModifiedTime shold change
492     [Documentation]    when create child contentInsntance, state should increase + lastModifiedTime shold not change
493     # CSE
494     #    |--Contianer2
495     #    |--ContentInstance
496     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
497     ${oldst} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
498     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
499     Sleep    2s
500     # We know Beryllium is going to be get rid of all sleep.
501     # But as lastModifiedTime has precision in seconds,
502     # we need to wait 1 second to see different value on update.
503     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
504     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
505     Should Be Equal As Integers    ${oldst+1}    ${r.json()['m2m:cnt']['st']}
506     Should Not Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${r.json()['m2m:cnt']['lt']}
507
508 4.314 stateTag should not be updated when update child container
509     [Documentation]    stateTag should not be updated when update child container
510     # CSE
511     #    |--Contianer2
512     #    |--Container3
513     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
514     ${oldst} =    Set Variable    ${oldr.json()['m2m:cnt']['st']}
515     ${attr} =    Set Variable    "lbl":["label45"]
516     Sleep    1s
517     # We know Beryllium is going to be get rid of all sleep.
518     # But as lastModifiedTime has precision in seconds,
519     # we need to wait 1 second to see different value on update.
520     Update Resource    ${iserver}    InCSE1/Container2/Container3    ${rt_container}    ${attr}
521     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
522     Should Be Equal As Integers    ${oldst}    ${r.json()['m2m:cnt']['st']}
523     ${lt2} =    LastModifiedTime    ${r}
524     Should Be Equal    ${oldr.json()['m2m:cnt']['lt']}    ${lt2}
525
526 Delete the Container2-4.3
527     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
528     #------------    4.    currentNrofInstance ------
529
530 4.41 when container create, cni should be 0
531     [Documentation]    when container create, cni should be 0
532     ${attr} =    Set Variable    "rn":"Container2"
533     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
534     ${container} =    Location    ${r}
535     ${status_code} =    Status Code    ${r}
536     ${oldr} =    Retrieve Resource    ${iserver}    ${container}
537     ${cni} =    Set Variable    ${oldr.json()['m2m:cnt']['cni']}
538     Should Be Equal As Integers    0    ${cni}
539
540 4.42 when conInstance create, parent container's cni should + 1
541     [Documentation]    when conInstance create, parent container's cni should + 1
542     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
543     ${oldcni} =    Set Variable    ${oldr.json()['m2m:cnt']['cni']}
544     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
545     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
546     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
547     Should Be Equal As Integers    ${oldcni+1}    ${r.json()['m2m:cnt']['cni']}
548     # Test again
549     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
550     ${oldcni} =    Set Variable    ${oldr.json()['m2m:cnt']['cni']}
551     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","rn":"contentIn1"
552     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
553     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
554     Should Be Equal As Integers    ${oldcni+1}    ${r.json()['m2m:cnt']['cni']}
555
556 4.43 when conInstance delete, parent container's cni should - 1
557     [Documentation]    Delete the conIn created in 4.42, when conInstance delete, parent container's cni should - 1
558     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
559     ${oldcni} =    Set Variable    ${oldr.json()['m2m:cnt']['cni']}
560     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
561     Delete Resource    ${iserver}    InCSE1/Container2/contentIn1
562     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
563     Should Be Equal As Integers    ${oldcni-1}    ${r.json()['m2m:cnt']['cni']}
564
565 Delete the Container2-4.4
566     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
567     # -------------    5. currentByteSize    -----------
568
569 4.51 when container create, cbs should be 0
570     [Documentation]    when container create, cbs should be 0
571     ${attr} =    Set Variable    "rn":"Container2"
572     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
573     ${container} =    Location    ${r}
574     ${status_code} =    Status Code    ${r}
575     ${oldr} =    Retrieve Resource    ${iserver}    ${container}
576     ${cbs} =    Set Variable    ${oldr.json()['m2m:cnt']['cbs']}
577     Should Be Equal As Integers    0    ${cbs}
578
579 4.52 when conInstance create, parent container's cbs should + cs
580     [Documentation]    when conInstance create, parent container's cbs should + cs
581     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
582     ${oldcbs} =    Set Variable    ${oldr.json()['m2m:cnt']['cbs']}
583     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
584     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
585     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
586     Should Be Equal As Integers    ${oldcbs+6}    ${r.json()['m2m:cnt']['cbs']}
587     # Test again
588     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
589     ${oldcbs} =    Set Variable    ${oldr.json()['m2m:cnt']['cbs']}
590     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"xxx%%!@","rn":"contentIn1"
591     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
592     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
593     Should Be Equal As Integers    ${oldcbs+7}    ${r.json()['m2m:cnt']['cbs']}
594
595 4.53 when conInstance delete, parent container's cbs should - cs
596     [Documentation]    Delete the conIn created in 4.52, when conInstance delete, parent container's cbs should - cs
597     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
598     ${oldcbs} =    Set Variable    ${oldr.json()['m2m:cnt']['cbs']}
599     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
600     Delete Resource    ${iserver}    InCSE1/Container2/contentIn1
601     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
602     Should Be Equal As Integers    ${oldcbs-7}    ${r.json()['m2m:cnt']['cbs']}
603
604 Delete the Container2-4.5
605     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
606     # -------------    6. maxNrOfInstances    ----------
607
608 4.61 if maxNrOfInstance = 1 , can create 1 contentInstance
609     [Documentation]    if maxNrOfInstance = 1 , can create 1 contentInstance
610     ${attr} =    Set Variable    "mni":1,"rn":"Container2"
611     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
612     ${container} =    Location    ${r}
613     ${status_code} =    Status Code    ${r}
614     ${oldr} =    Retrieve Resource    ${iserver}    ${container}
615     ${mni} =    Set Variable    ${oldr.json()['m2m:cnt']['mni']}
616     Should Be Equal As Integers    1    ${mni}
617     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
618     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
619
620 4.62 if maxNrOfInstance = 1 , when create 2 contentInstance, the first one should be deleted
621     [Documentation]    if maxNrOfInstance = 1 , cannot create 2 contentInstance
622     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
623     # cannot create 2
624     ${rr} =    Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
625     Check Response and Retrieve Resource    ${rr}
626     ${rr} =    Retrieve resource    ${iserver}    InCSE1/Container2
627     ${chr} =    Set Variable    ${rr.json()['m2m:cnt']['ch']}
628     ${cbs} =    Set Variable    ${rr.json()['m2m:cnt']['cbs']}
629     Should Be Equal As Integers    ${rr.json()['m2m:cnt']['cni']}    1
630     ${childNumber} =    Get Length    ${chr}
631     Should Be Equal As Integers    ${childNumber}    1
632
633 4.63 if update to 3 , when create 4 or more contentInstance, the current number instance should be 3
634     [Documentation]    if update to 3 , cannot create 4 contentInstance
635     ${attr} =    Set Variable    "mni":3
636     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
637     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
638     # create 3
639     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
640     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
641     #Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
642     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
643     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
644     ${mni} =    Set Variable    ${rr.json()['m2m:cnt']['mni']}
645     ${chr} =    Set Variable    ${rr.json()['m2m:cnt']['ch']}
646     Should Be Equal As Integers    ${mni}    3
647
648 4.64 what if alread have 4, then set mni to 1
649     [Documentation]    if alread have 4, then set mni to 1, will delete 3 children
650     ${attr} =    Set Variable    "mni":1
651     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
652     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
653     ${chr} =    Set Variable    ${rr.json()['m2m:cnt']['ch']}
654     ${mni} =    Set Variable    ${rr.json()['m2m:cnt']['mni']}
655     Should Be Equal As Integers    ${rr.json()['m2m:cnt']['cni']}    1
656
657 Delete the Container2-4.6
658     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
659     # -------------    7. maxByteSize -------
660
661 4.71 if maxByteSize = 5 , can create contentInstance with contentSize 5
662     [Documentation]    if maxByteSize = 5 , can create contentInstance with contentSize 5
663     ${attr} =    Set Variable    "mbs":5,"rn":"Container2"
664     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}
665     ${container} =    Location    ${r}
666     ${status_code} =    Status Code    ${r}
667     ${oldr} =    Retrieve Resource    ${iserver}    ${container}
668     ${mbs} =    Set Variable    ${oldr.json()['m2m:cnt']['mbs']}
669     Should Be Equal As Integers    5    ${mbs}
670
671 4.72 if maxByteSize = 5 , cannot create contentInstance with contenSize 8
672     [Documentation]    if maxByteSize = 5 , cannot create contentInstance with contenSize 8
673     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102C120c"
674     # cannot create 2
675     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}
676     ...    ${attr}
677     Should Start with    ${error}    Cannot create this resource [400]
678
679 4.73 if update to 20 , cannot create another contentInstance
680     [Documentation]    if update to 20 , cannot create another contentInstance
681     ${attr} =    Set Variable    "mbs":20
682     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
683     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CS"
684     # create 4 cin
685     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
686     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
687     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
688     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
689     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
690     ${cbs} =    Set Variable    ${rr.json()['m2m:cnt']['cbs']}
691     ${chr} =    Set Variable    ${rr.json()['m2m:cnt']['ch']}
692     Should Be Equal As Integers    ${rr.json()['m2m:cnt']['cni']}    4
693     ${childNumber} =    Get Length    ${chr}
694     Should Be Equal As Integers    ${childNumber}    4
695
696 4.74 if alread have 20, then set mbs to 5,will delete contentInstance until mbs less than 5.
697     [Documentation]    what if alread have 20, then set mbs to 5, will delete contentInstance until mbs less than 5.
698     ${attr} =    Set Variable    "mbs":5
699     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
700     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
701     ${chr} =    Set Variable    ${rr.json()['m2m:cnt']['ch']}
702     ${cbs} =    Set Variable    ${rr.json()['m2m:cnt']['cbs']}
703     Should Be Equal As Integers    ${rr.json()['m2m:cnt']['cni']}    1
704     ${childNumber} =    Get Length    ${chr}
705     Should Be Equal As Integers    ${childNumber}    1
706
707 Delete the Container2-4.7
708     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
709
710 4.81 creator -- value must be null
711     [Documentation]    creator -- value must be null
712     ${attr} =    Set Variable    "cr":"VALUE"
713     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container1    ${rt_container}
714     ...    ${attr}
715     Should Start with    ${error}    Cannot create this resource [400]
716     Should Contain    ${error}    error    cr
717     #==================================================
718     #    Finish
719     #==================================================
720
721 Delete the test Container1
722     [Documentation]    Delete the test Container1
723     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container1
724
725 *** Keywords ***
726 Check Response and Retrieve Resource
727     [Arguments]    ${r}
728     ${con} =    Location    ${r}
729     ${status_code} =    Status Code    ${r}
730     Should Be True    199 < ${status_code} < 299
731     ${rr} =    Retrieve Resource    ${iserver}    ${con}
732     ${text} =    Text    ${rr}
733     [Return]    ${text}
734
735 Check Response and Retrieve Resource For Update
736     [Arguments]    ${r}    ${location}
737     ${status_code} =    Status Code    ${r}
738     Should Be True    199 < ${status_code} < 299
739     ${rr} =    Retrieve Resource    ${iserver}    ${location}
740     ${text} =    Text    ${rr}
741     [Return]    ${text}
742
743 Cannot Create Container Error
744     [Arguments]    ${attr}
745     [Documentation]    create Container Under InCSE1 and expect error
746     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_container}
747     ...    ${attr}
748     Should Start with    ${error}    Cannot create this resource [400]
749     [Return]    ${error}
750
751 Cannot Update Container Error
752     [Arguments]    ${attr}
753     [Documentation]    update Container Under InCSE1 and expect error
754     ${error} =    Run Keyword And Expect Error    *    Update Resource    ${iserver}    InCSE1/Container1    ${rt_container}
755     ...    ${attr}
756     Should Start with    ${error}    Cannot update this resource [400]
757     [Return]    ${error}