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