39d7a4dac7eb16f80ac14cf5f4e4eeb5badd8998
[integration/test.git] / test / csit / suites / iotdm / basic / 060_ConInAttributeTest.robot
1 *** Settings ***
2 Suite Teardown    Kill The Tree    ${CONTROLLER}    InCSE1    admin    admin
3 Library           ../../../libraries/criotdm.py
4 Library           Collections
5
6 *** Variables ***
7 ${httphost}       ${CONTROLLER}
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     #==================================================
18     #    Container Mandatory Attribute Test
19     #==================================================
20     # mandatory attribute: content
21     # cse
22     #    |
23     #    ---Container1
24     #    |
25     #    ----conIn1
26     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
27     Set Suite Variable    ${iserver}
28
29 1.1 After Created, test whether all the mandatory attribtues are exist.
30     [Documentation]    create 1 conIn test whether all the mandatory attribtues are exist
31     ${attr} =    Set Variable
32     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container1
33     ${container} =    Name    ${r}
34     ${status_code} =    Status Code    ${r}
35     Should Be Equal As Integers    ${status_code}    201
36     ${attr} =    Set Variable    "con":"102CSS"
37     Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}    ${attr}    conIn1
38     ${text} =    Text    ${r}
39     Should Contain    ${text}    "ri":    "rn":    "cs":
40     Should Contain    ${text}    "lt":    "pi":    "con":
41     Should Contain    ${text}    "ct":    "rty":4
42     Should Not Contain    S{text}    "lbl"    "creator"    "or"
43
44 1.21 Missing content should return error
45     [Documentation]    Missing content should return error
46     ${attr} =    Set Variable
47     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}
48     ...    ${attr}
49     Should Start with    ${error}    Cannot create this resource [400]
50     Should Contain    ${error}    CONTENT    missing
51     #===========================================================
52     #    ContentInstance Optional Attribute Test (Allowed)
53     #===========================================================
54     #    create--> delete
55     #    Cannot be updated
56     # Optional attribute: [aa,at],contentInfo, ontologyRef, label, creator
57
58 2.11 ContentInfo (cnf) can be added when create
59     [Documentation]    ContentInfo (cnf) can be added when create
60     ${attr} =    Set Variable    "cnf": "1","con":"102CSS"
61     # create conIn under Container1
62     ${r}=    Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}    ${attr}    conIn2
63     ${text} =    Check Create and Retrieve ContentInstance    ${r}
64     Should Contain    ${text}    cnf
65
66 Delete the ContenInstance 2.1
67     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container1/conIn2
68
69 2.12 ContentInfo (cnf) cannot be updated
70     [Documentation]    ContentInfo (cnf) cannot be updated
71     ${attr} =    Set Variable    "cnf": "1"
72     ${error} =    Cannot Update ContentInstance Error    ${attr}
73     Should Contain    ${error}    Not permitted to update content
74
75 2.21 OntologyRef (or) can be added when create
76     [Documentation]    OntologyRef (or) can be added when create
77     ${attr} =    Set Variable    "or": "http://cisco.com","con":"102CSS"
78     # create conIn under Container1
79     ${r}=    Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}    ${attr}    conIn2
80     ${text} =    Check Create and Retrieve ContentInstance    ${r}
81     Should Contain    ${text}    or
82
83 Delete the ContenInstance 2.2
84     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container1/conIn2
85
86 2.22 OntologyRef (or) cannot be updated
87     [Documentation]    OntologyRef (or) cannot be updated
88     ${attr} =    Set Variable    "or": "1"
89     ${error} =    Cannot Update ContentInstance Error    ${attr}
90     Should Contain    ${error}    Not permitted to update content
91
92 2.31 labels[single] can be added when create
93     [Documentation]    create conIn under Container1, labels[single] can be added when create
94     ${attr} =    Set Variable    "lbl":["ds"],"con":"102CSS"
95     ${r}=    Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}    ${attr}    conIn2
96     ${text} =    Check Create and Retrieve ContentInstance    ${r}
97     Should Contain    ${text}    lbl
98
99 Delete the ContenInstance 2.31
100     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container1/conIn2
101
102 2.32 labels (single) cannot be updated
103     [Documentation]    update labels then expect error
104     ${attr} =    Set Variable    "lbl":["1"]
105     ${error} =    Cannot Update ContentInstance Error    ${attr}
106     Should Contain    ${error}    Not permitted to update content
107
108 2.33 labels (multiple) can be added when create
109     [Documentation]    labels (multiple) can be added when create
110     ${attr} =    Set Variable    "lbl":["http://cisco.com","dsds"],"con":"102CSS"
111     # create conIn under Container1
112     ${r}=    Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}    ${attr}    conIn2
113     ${text} =    Check Create and Retrieve ContentInstance    ${r}
114     Should Contain    ${text}    lbl
115
116 Delete the ContenInstance 2.33
117     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container1/conIn2
118
119 2.34 labels (multiple) cannot be updated
120     [Documentation]    labels (multiple) cannot be updated
121     ${attr} =    Set Variable    "lbl":["1"]
122     ${error} =    Cannot Update ContentInstance Error    ${attr}
123     Should Contain    ${error}    Not permitted to update content
124     #=================================================================
125     #    contentInstance Disturbing Attribute Test, Not Allowed Update
126     #=================================================================
127     # using non-valid attribtue to create then expext error
128
129 3.11 Mulitiple labels should return error
130     [Documentation]    Mulitiple labels should return error
131     ${attr} =    Set Variable    "con": "1", "lbl":["label1"],"lbl":["label2"]
132     ${error} =    Cannot Craete ContentInstance Error    ${attr}
133     Should Contain    ${error}    Duplicate    lbl
134
135 3.12 Multiple creator should return error
136     [Documentation]    Multiple creator should return error
137     ${attr} =    Set Variable    "con": "1", "cr":null, "cr":null
138     ${error} =    Cannot Craete ContentInstance Error    ${attr}
139     Should Contain    ${error}    Duplicate    cr
140
141 3.13 Multiple contentInfo should return error
142     [Documentation]    Multiple contentInfo should return error
143     ${attr} =    Set Variable    "con": "1", "cnf":"1","cnf":"2"
144     ${error} =    Cannot Craete ContentInstance Error    ${attr}
145     Should Contain    ${error}    Duplicate    cnf
146
147 3.14 Multiple ontologyRef should return error
148     [Documentation]    Multiple ontologyRef should return error
149     ${attr} =    Set Variable    "con": "1", "or":"http://cisco.com","or":"http://google.com"
150     ${error} =    Cannot Craete ContentInstance Error    ${attr}
151     Should Contain    ${error}    Duplicate    or
152
153 3.15 Mulptiple content should return error
154     [Documentation]    Mulptiple content should return error
155     ${attr} =    Set Variable    "con": "1", "con":"2313"
156     ${error} =    Cannot Craete ContentInstance Error    ${attr}
157     Should Contain    ${error}    Duplicate    con
158     #----------------All attributes cannot be updated----------
159
160 3.21 resourceType cannot be updated.
161     [Documentation]    update resourceType and expect error
162     ${attr} =    Set Variable    "rt": 3
163     ${error} =    Cannot Update ContentInstance Error    ${attr}
164     Should Contain    ${error}    Not permitted to update content
165
166 3.22 resourceId cannot be updated.
167     [Documentation]    update resourceId and expect error
168     ${attr} =    Set Variable    "ri": "e4e43"
169     ${error} =    Cannot Update ContentInstance Error    ${attr}
170     Should Contain    ${error}    Not permitted to update content
171
172 3.23 resourceName cannot be updated.
173     [Documentation]    update resourceName and expect error
174     ${attr} =    Set Variable    "rn": "4343"
175     ${error} =    Cannot Update ContentInstance Error    ${attr}
176     Should Contain    ${error}    Not permitted to update content
177
178 3.24 parentId cannot be updated.
179     [Documentation]    update parentID and expect error
180     ${attr} =    Set Variable    "pi": "InCSE2/ERE"
181     ${error} =    Cannot Update ContentInstance Error    ${attr}
182     Should Contain    ${error}    Not permitted to update content
183
184 3.25 cretionTime cannot be updated.
185     [Documentation]    update createTime and expect error
186     ${attr} =    Set Variable    "ct": "343434T34322"
187     ${error} =    Cannot Update ContentInstance Error    ${attr}
188     Should Contain    ${error}    Not permitted to update content
189
190 3.26 lastmodifiedTime cannot be updated.
191     [Documentation]    update lt then expect error
192     ${attr} =    Set Variable    "lt": "434343T23232"
193     ${error} =    Cannot Update ContentInstance Error    ${attr}
194     Should Contain    ${error}    Not permitted to update content
195
196 3.27 contentSize cannot be updated.
197     [Documentation]    update contentSize then expect error
198     ${attr} =    Set Variable    "cs": 232
199     ${error} =    Cannot Update ContentInstance Error    ${attr}
200     Should Contain    ${error}    Not permitted to update content
201
202 3.28 content cannot be updated
203     [Documentation]    update content then expect error
204     ${attr} =    Set Variable    "con": "1"
205     ${error} =    Cannot Update ContentInstance Error    ${attr}
206     Should Contain    ${error}    Not permitted to update content
207     #==================================================
208     #    Functional Attribute Test
209     #==================================================
210     # Next step:
211     # creator
212     # contentSzie
213     # contentInfo
214     # content
215     #==================================================
216     #    Finish
217     #==================================================
218
219 Delete the test Container1
220     [Documentation]    Delete the test Container1
221     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container1
222
223 *** Keywords ***
224 Cannot Update ContentInstance Error
225     [Arguments]    ${attr}
226     ${error} =    Run Keyword And Expect Error    *    update Resource    ${iserver}    InCSE1/Container1/conIn1    ${rt_contentInstance}
227     ...    ${attr}
228     Should Start with    ${error}    Cannot update this resource [405]
229     [Return]    ${error}
230
231 Cannot Craete ContentInstance Error
232     [Arguments]    ${attr}
233     ${error} =    Run Keyword And Expect Error    *    create Resource    ${iserver}    InCSE1/Container1/conIn1    ${rt_contentInstance}
234     ...    ${attr}
235     Should Start with    ${error}    Cannot create this resource [400]
236     [Return]    ${error}
237
238 Check Create and Retrieve ContentInstance
239     [Arguments]    ${r}
240     ${con} =    Name    ${r}
241     ${status_code} =    Status Code    ${r}
242     Should Be Equal As Integers    ${status_code}    201
243     ${rr} =    Retrieve Resource    ${iserver}    ${con}
244     ${text} =    Text    ${rr}
245     [Return]    ${text}