Tidy new and updated test suites.
[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     ${count} =    Get Length    ${r.json()['m2m:cnt']['ch']}
118     Should Be Equal As Integers    ${count}    2
119     # 7. expireBefore
120     # 8. expireAfter
121
122 9. labels
123     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/Container3    rcn=4&sts=3&lbl=contentInstanceUnderContainerContainer
124     ${count} =    Get Length    ${r.json()['ch']}
125     Should Be Equal As Integers    ${count}    2
126     # 2 labels test
127
128 10. resourceType
129     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3
130     ${count} =    Get Length    ${r.json()['ch']}
131     Should Be Equal As Integers    ${count}    3
132
133 11. sizeAbove
134     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3&sza=5
135     ${count} =    Get Length    ${r.json()['ch']}
136     Should Be Equal As Integers    ${count}    2
137
138 12. sizeBelow
139     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3&szb=5
140     ${count} =    Get Length    ${r.json()['ch']}
141     Should Be Equal As Integers    ${count}    1
142
143 2.1 And Test - labels
144     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    fu=1&rcn=4&sts=4&lbl=contentInstanceUnderContainerContainer&lbl=underCSE
145     ${count} =    Get Length    ${r.json()}
146     Should Be Equal As Integers    ${count}    6
147
148 *** Keywords ***
149 Connect And Create The Tree
150     [Documentation]    Create a tree that contain AE/ container / contentInstance in different layers
151     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
152     ${attr} =    Set Variable    "api":"jb","apn":"jb2","or":"http://hey/you","rr":true
153     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AE1"
154     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AE2"
155     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr},"rn":"AE3"
156     Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    "rn":"Container1"
157     Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    "rn":"Container2"
158     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underCSE"]
159     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr},"rn":"Container3"
160     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr},"rn":"Container4"
161     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr},"rn":"Container5"
162     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underAEContainer"]
163     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_container}    ${attr},"rn":"Container6"
164     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underCSEContainer"]
165     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr},"rn":"Container7"
166     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr},"rn":"Container8"
167     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr},"rn":"Container9"
168     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderAEContainer"]
169     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_contentInstance}    ${attr},"rn":"conIn1"
170     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_contentInstance}    ${attr},"rn":"conIn2"
171     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderContainerContainer"]
172     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr},"rn":"conIn3"
173     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr},"rn":"conIn4"
174     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr},"rn":"conIn5"
175     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderContainer"]
176     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr},"rn":"conIn6"
177     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr},"rn":"conIn7"
178     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr},"rn":"conIn8"