Update iotdm library and tests.
[integration/test.git] / csit / suites / iotdm / basic / 080_FilterCriteriaTest.robot
1 *** Settings ***
2 Suite Setup       Connect And Create The Tree
3 Suite Teardown    Kill The Tree    ${ODL_SYSTEM_IP}    InCSE1    admin    admin
4 Library           ../../../libraries/criotdm.py
5 Library           Collections
6
7 *** Variables ***
8 ${httphost}       ${ODL_SYSTEM_IP}
9 ${httpuser}       admin
10 ${httppass}       admin
11 ${rt_ae}          2
12 ${rt_container}    3
13 ${rt_contentInstance}    4
14
15 *** Test Cases ***
16 Set Suite Variable
17     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
18     Set Suite Variable    ${iserver}
19     #==================================================
20     #    ResultContent(rcn) Test
21     #==================================================
22
23 1.1 rcn is legal in create
24     [Documentation]    rcn=1, 2, 3, 0 is legal
25     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
26     : FOR    ${rcn}    IN    \    1    2    3
27     ...    0
28     \    ${r} =    Create Resource With Command    ${iserver}    InCSE1    ${rt_ae}    rcn=${rcn}
29     \    ...    ${attr}
30
31 1.2 rcn is illegal in create
32     [Documentation]    rcn=4, 5, 6, 7 is illegal
33     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
34     : FOR    ${rcn}    IN    4    5    6    7
35     \    ${error} =    Run Keyword And Expect Error    *    Create Resource With Command    ${iserver}    InCSE1
36     \    ...    ${rt_ae}    rcn=${rcn}    ${attr}
37     \    Should Start with    ${error}    Cannot create this resource [400]
38     \    Should Contain    ${error}    rcn
39
40 2.1 rcn is legal in update
41     [Documentation]    rcn=1, 0/ null is legal
42     ${attr} =    Set Variable    "or":"http://hey/you"
43     : FOR    ${rcn}    IN    \    0    1    5
44     ...    6
45     \    ${r} =    Update Resource With Command    ${iserver}    InCSE1/AE1    ${rt_ae}    rcn=${rcn}
46     \    ...    ${attr}
47
48 2.2 rcn is illegal in update
49     [Documentation]    rcn=2, 3, 7 is illegal
50     ${attr} =    Set Variable    "or":"http://hey/you"
51     : FOR    ${rcn}    IN    2    3    4    7
52     \    ${error} =    Run Keyword And Expect Error    *    Update Resource With Command    ${iserver}    InCSE1/AE1
53     \    ...    ${rt_ae}    rcn=${rcn}    ${attr}
54     \    Should Start with    ${error}    Cannot update this resource [400]
55     \    Should Contain    ${error}    rcn
56
57 3.1 rcn is legal in retrieve
58     [Documentation]    rcn=1, 4, 5, 6 null is legal
59     : FOR    ${rcn}    IN    \    1    4    5
60     ...    6
61     \    ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=${rcn}
62     # when rcn=7 can be retrieved
63
64 3.2 rcn is illegal in retrieve
65     [Documentation]    rcn=0, 2, 3 is illegal
66     : FOR    ${rcn}    IN    0    2    3
67     \    ${error} =    Run Keyword And Expect Error    *    Retrieve Resource With Command    ${iserver}    InCSE1/AE1
68     \    ...    rcn=${rcn}
69     \    Should Start with    ${error}    Cannot retrieve this resource [400]
70     \    Should Contain    ${error}    rcn
71
72 4.2 rcn is illegal in delete
73     [Documentation]    rcn=2, 3, 4, 5, 6, 7 is illegal
74     ${attr} =    Set Variable    "or":"http://hey/you"
75     : FOR    ${rcn}    IN    2    3    4    7
76     \    ${error} =    Run Keyword And Expect Error    *    Delete Resource With Command    ${iserver}    InCSE1/AE1
77     \    ...    rcn=${rcn}
78     \    Should Start with    ${error}    Cannot delete this resource [400]
79     \    Should Contain    ${error}    rcn
80
81 Delete the tree
82     Kill The Tree    ${ODL_SYSTEM_IP}    InCSE1    admin    admin
83     #==================================================
84     #    FilterCriteria Test
85     #==================================================
86
87 Create the tree
88     Connect And Create The Tree
89
90 1. createdBefore
91     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&crb=20160612T033748Z
92     ${count} =    Get Length    ${r.json()['m2m:ae']['ch']}
93     Should Be Equal As Integers    ${count}    2
94
95 2. createdAfter
96     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&cra=20150612T033748Z
97     ${count} =    Get Length    ${r.json()['m2m:ae']['ch']}
98     Should Be Equal As Integers    ${count}    2
99
100 3. modifiedSince
101     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&ms=20150612T033748Z
102     ${count} =    Get Length    ${r.json()['m2m:ae']['ch']}
103     Should Be Equal As Integers    ${count}    2
104
105 4. unmodifiedSince
106     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&us=20160612T033748Z
107     ${count} =    Get Length    ${r.json()['m2m:ae']['ch']}
108     Should Be Equal As Integers    ${count}    2
109
110 5. stateTagSmaller
111     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/Container3    rcn=4&sts=3
112     ${count} =    Get Length    ${r.json()['ch']}
113     Should Be Equal As Integers    ${count}    5
114
115 6. stateTagBigger
116     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/Container3    rcn=4&stb=1
117
118     ${count} =    Get Length    ${r.json()['m2m:cnt']['ch']}
119     Should Be Equal As Integers    ${count}    2
120     # 7. expireBefore
121     # 8. expireAfter
122
123 9. labels
124     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/Container3    rcn=4&sts=3&lbl=contentInstanceUnderContainerContainer
125     ${count} =    Get Length    ${r.json()['ch']}
126     Should Be Equal As Integers    ${count}    2
127     # 2 labels test
128
129 10. resourceType
130     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3
131     ${count} =    Get Length    ${r.json()['ch']}
132     Should Be Equal As Integers    ${count}    3
133
134 11. sizeAbove
135     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3&sza=5
136     ${count} =    Get Length    ${r.json()['ch']}
137     Should Be Equal As Integers    ${count}    2
138
139 12. sizeBelow
140     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3&szb=5
141     ${count} =    Get Length    ${r.json()['ch']}
142     Should Be Equal As Integers    ${count}    1
143
144 2.1 And Test - labels
145
146     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    fu=1&rcn=4&sts=4&lbl=contentInstanceUnderContainerContainer&lbl=underCSE
147     ${count} =    Get Length    ${r.json()}
148     Should Be Equal As Integers    ${count}    6
149
150 *** Keywords ***
151 Connect And Create The Tree
152     [Documentation]    Create a tree that contain AE/ container / contentInstance in different layers
153     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
154     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
155     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AE1"
156     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AE2"
157     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AE3"
158     Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    "rn":"Container1"
159     Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    "rn":"Container2"
160     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underCSE"]
161     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr},"rn":"Container3"
162     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr},"rn":"Container4"
163     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr},"rn":"Container5"
164     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underAEContainer"]
165     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_container}    ${attr},"rn":"Container6"
166     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underCSEContainer"]
167     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr},"rn":"Container7"
168     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr},"rn":"Container8"
169     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr},"rn":"Container9"
170     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderAEContainer"]
171     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_contentInstance}    ${attr},"rn":"conIn1"
172     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_contentInstance}    ${attr},"rn":"conIn2"
173     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderContainerContainer"]
174     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr},"rn":"conIn3"
175     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr},"rn":"conIn4"
176     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr},"rn":"conIn5"
177     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderContainer"]
178     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr},"rn":"conIn6"
179     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr},"rn":"conIn7"
180     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr},"rn":"conIn8"