Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Setup and Teardown Functionality for XOS API Tests |
| 3 | Library Collections |
| 4 | Library String |
| 5 | Library OperatingSystem |
| 6 | Library XML |
| 7 | Library RequestsLibrary |
| 8 | Library HttpLibrary.HTTP |
| 9 | Library ../Framework/utils/utils.py |
| 10 | Library ../Framework/restApi.py |
| 11 | Variables ../Properties/RestApiProperties.py |
| 12 | |
| 13 | *** Keywords *** |
| 14 | Verify API Functionality |
| 15 | [Arguments] ${type} ${endpoint} ${data}=${EMPTY} ${data_id}=${EMPTY} ${key}=${EMPTY} |
| 16 | Run Keyword If "${type}" == "RETRIEVE" CORD Get ${endpoint} ${data_id} ${data} ${key} |
| 17 | Run Keyword If "${type}" == "CREATE" CORD Post ${endpoint} ${data} |
| 18 | Run Keyword If "${type}" == "UPDATE" CORD Put ${endpoint} ${data} ${data_id} |
| 19 | Run Keyword If "${type}" == "DELETE" CORD Delete ${endpoint} ${data_id} |
| 20 | |
| 21 | CORD Get |
| 22 | [Documentation] Make a GET call to the CORD controller |
| 23 | [Arguments] ${service} ${id} ${value} ${key} |
| 24 | ${resp}= Get Request ${SERVER_IP} ${service}/${id} |
| 25 | Log ${resp.content} |
| 26 | Should Be Equal As Strings ${resp.status_code} 200 |
| 27 | ${updated_value}= Run Keyword If '${key}' != 'null' Get Json Value ${resp.content} /${key} |
| 28 | ${updated_value}= Run Keyword If '${key}' != 'null' Remove String ${updated_value} " |
| 29 | Run Keyword If '${key}' != 'null' Should Contain "${value}" ${updated_value} |
| 30 | [Return] ${resp} |
| 31 | |
| 32 | CORD Post |
| 33 | [Documentation] Make a POST call to the CORD controller |
| 34 | [Arguments] ${service} ${data} |
| 35 | ${data}= Evaluate json.dumps(${data}) json |
| 36 | ${resp}= Post Request ${SERVER_IP} uri=${service} data=${data} |
| 37 | Log ${resp.content} |
| 38 | Should Be Equal As Strings ${resp.status_code} 200 |
| 39 | ${id}= Get Json Value ${resp.content} /id |
| 40 | Set Suite Variable ${id} |
| 41 | [Return] ${resp} |
| 42 | |
| 43 | CORD Put |
| 44 | [Documentation] Make a PUT call to the CORD controller |
| 45 | [Arguments] ${service} ${data} ${data_id} |
| 46 | ${data}= Evaluate json.dumps(${data}) json |
| 47 | ${resp}= Put Request ${SERVER_IP} uri=${service}/${data_id} data=${data} |
| 48 | Log ${resp.content} |
| 49 | Should Be Equal As Strings ${resp.status_code} 200 |
| 50 | ${id}= Get Json Value ${resp.content} /id |
| 51 | Set Suite Variable ${id} |
| 52 | [Return] ${resp} |
| 53 | |
| 54 | CORD Delete |
| 55 | [Documentation] Make a DELETE call to the CORD controller |
| 56 | [Arguments] ${service} ${data_id} |
| 57 | ${resp}= Delete Request ${SERVER_IP} uri=${service}/${data_id} |
| 58 | Log ${resp.content} |
| 59 | Should Be Equal As Strings ${resp.status_code} 200 |
| 60 | [Return] ${resp} |
| 61 | |
| 62 | Generate JSON Data |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 63 | {%- for m in proto.messages -%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 64 | {%- if m.name not in ['XOSBase'] -%} |
| 65 | {% autoescape false %} |
| 66 | {% endautoescape %} |
| 67 | ${json_{{ m.name | lower }}_1}= Set Variable { } |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 68 | ${json_{{ m.name | lower }}_amend_1}= Set Variable { } |
| 69 | ${json_{{ m.name | lower}}_amend_key}= Set Variable null |
| 70 | Set Suite Variable ${json_{{ m.name | lower}}_amend_key} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 71 | # set required fields for {{ m.name | lower }} object |
| 72 | {% for f in m.fields + xproto_base_fields(m, proto.message_table) -%} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 73 | {% if f.modifier == "required" and f.options.blank != "True" -%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 74 | {% if not f.options.default -%} |
| 75 | {% if f.link -%} |
| 76 | ${tmp_{{ f.options.model | lower }}_id}= Create {{ f.options.model }} |
| 77 | ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }}_id ${tmp_{{ f.options.model | lower }}_id} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 78 | {% elif f.name == "created" or f.name == "amend" or f.name =="expires" or f.name =='granted' -%} |
| 79 | ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value float |
| 80 | ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}" |
| 81 | {% elif f.name == "role" -%} |
| 82 | ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value role |
| 83 | ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}" |
| 84 | {% elif f.name == "direction" -%} |
| 85 | ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value direction |
| 86 | ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}" |
| 87 | {% elif f.name == "flavor" -%} |
| 88 | ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value flavor |
| 89 | ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}" |
Kailash Khalasi | 01f410f | 2018-10-12 11:54:19 -0700 | [diff] [blame] | 90 | {% elif f.name == "s_tag" and m.name == "BNGPortMapping" -%} |
Kailash Khalasi | 1f7f30b | 2018-10-12 11:27:17 -0700 | [diff] [blame] | 91 | ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value vlan_tag |
| 92 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_1}" |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 93 | {% else -%} |
| 94 | ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value {{ f.type }} |
| 95 | ${json_{{ m.name | lower }}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_1}" |
Kailash Khalasi | 7209066 | 2018-08-13 17:50:46 -0700 | [diff] [blame] | 96 | {% if f.name == "created" or f.name == "amend" or f.name =="expires" or f.name =='granted' -%} |
| 97 | ${json_{{ m.name | lower}}_{{ f.name }}_1}= Generate Random Value float |
| 98 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_1}" |
| 99 | {% else -%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 100 | {% if loop.index0 == 0 -%} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 101 | ${json_{{ m.name | lower}}_amend_key}= Set Variable {{ f.name }} |
| 102 | ${json_{{ m.name | lower}}_{{ f.name }}_amend_1}= Generate Random Value {{ f.type }} |
| 103 | ${json_{{ m.name | lower }}_amend_1}= Set Json Value ${json_{{ m.name | lower }}_amend_1} /{{ f.name }} "${json_{{ m.name | lower }}_{{ f.name }}_amend_1}" |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 104 | {% endif -%} |
| 105 | {% endif -%} |
| 106 | {% endif -%} |
| 107 | {% endif -%} |
Kailash Khalasi | 1aae9d1 | 2018-08-13 18:14:30 -0700 | [diff] [blame] | 108 | {% endif -%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 109 | {% endfor -%} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 110 | {% if m.name == "User" -%} |
| 111 | ${json_{{ m.name | lower}}_email}= Set Variable testuser@opencord.org |
| 112 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /email "${json_{{ m.name | lower }}_email}" |
| 113 | ${json_{{ m.name | lower}}_email_amend_1}= Set Variable testuseramend@opencord.org |
| 114 | ${json_{{ m.name | lower}}_amend_1}= Set Json Value ${json_{{ m.name | lower }}_amend_1} /email "${json_{{ m.name | lower }}_email_amend_1}" |
| 115 | {% endif %} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 116 | {% if m.name == "Site" -%} |
| 117 | ${json_{{ m.name | lower}}_login_base_tmp}= Set Variable testloginbase |
| 118 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /login_base "${json_{{ m.name | lower }}_login_base_tmp}" |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 119 | {% endif %} |
| 120 | {% if m.name == "Flavor" -%} |
| 121 | ${json_{{ m.name | lower}}_flavor_tmp}= Set Variable m1.small |
| 122 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /flavor "${json_{{ m.name | lower }}_flavor_tmp}" |
| 123 | {% endif %} |
| 124 | {% if m.name == "ServiceGraphConstraint" -%} |
| 125 | ${json_{{ m.name | lower}}_constraints_tmp}= Generate Random Value string |
| 126 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /constraints "${json_{{ m.name | lower }}_constraints_tmp}" |
| 127 | {% endif %} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 128 | {% if m.name == "Slice" -%} |
| 129 | ${json_{{ m.name | lower}}_name}= Generate Random Slice Name |
| 130 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /name "${json_{{ m.name | lower }}_name}" |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 131 | ${json_{{ m.name | lower}}_name_amend_1}= Generate Random Slice Name |
| 132 | ${json_{{ m.name | lower}}_amend_1}= Set Json Value ${json_{{ m.name | lower }}_amend_1} /name "${json_{{ m.name | lower}}_name_amend_1}" |
Kailash Khalasi | d0d849d | 2018-08-28 18:34:24 -0700 | [diff] [blame] | 133 | {% endif -%} |
| 134 | {% if m.name == "ProgranServiceInstance" -%} |
| 135 | ${json_{{ m.name | lower}}_name}= Generate Random Value string |
| 136 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /name "${json_{{ m.name | lower }}_name}" |
| 137 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /CellIndividualOffset "1" |
Kailash Khalasi | d81b26c | 2018-09-12 09:06:29 -0700 | [diff] [blame] | 138 | ${json_{{ m.name | lower}}_name_amend_1}= Generate Random Value string |
| 139 | ${json_{{ m.name | lower}}_amend_1}= Set Json Value ${json_{{ m.name | lower }}_amend_1} /name "${json_{{ m.name | lower}}_name_amend_1}" |
| 140 | ${json_{{ m.name | lower}}_amend_1}= Set Json Value ${json_{{ m.name | lower }}_amend_1} /CellIndividualOffset "1" |
Kailash Khalasi | d0d849d | 2018-08-28 18:34:24 -0700 | [diff] [blame] | 141 | {% endif %} |
| 142 | {% if m.name == "RCORDSubscriber" -%} |
Kailash | c911307 | 2018-11-02 09:15:17 -0700 | [diff] [blame] | 143 | ## Create req service owner for rcord subscriber and |
Kailash Khalasi | d0d849d | 2018-08-28 18:34:24 -0700 | [diff] [blame] | 144 | CORD Post /xosapi/v1/rcord/rcordservices {"name": "testrcordservice", "access": "unknown"} |
| 145 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /owner_id ${id} |
Kailash | a2848a4 | 2018-11-02 09:36:41 -0700 | [diff] [blame] | 146 | ${rcord_tmp_service_id}= Set Variable ${id} |
| 147 | Set Suite Variable ${rcord_tmp_service_id} |
Kailash Khalasi | d0d849d | 2018-08-28 18:34:24 -0700 | [diff] [blame] | 148 | {% endif %} |
| 149 | {% if m.name == "HippieOSSServiceInstance" -%} |
| 150 | ## Create req service owner for hippie oss service instance |
| 151 | CORD Post /xosapi/v1/hippie-oss/hippieossservices {"name": "testhippieservice"} |
| 152 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /owner_id ${id} |
| 153 | {% endif %} |
Kailash | cc8e505 | 2019-02-06 12:17:54 -0800 | [diff] [blame] | 154 | {% if m.name == "MCordSubscriberInstance" -%} |
| 155 | ## Create req service owner for hippie oss service instance |
| 156 | CORD Post /xosapi/v1/mcord/mcordsubscriberservices {"name": "testmcordservice"} |
| 157 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /owner_id ${id} |
| 158 | {% endif %} |
Kailash Khalasi | d0d849d | 2018-08-28 18:34:24 -0700 | [diff] [blame] | 159 | {% if m.name == "AddressManagerServiceInstance" -%} |
| 160 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /public_ip "2.2.2.2" |
Kailash Khalasi | d81b26c | 2018-09-12 09:06:29 -0700 | [diff] [blame] | 161 | ${json_{{ m.name | lower}}_amend_1}= Set Json Value ${json_{{ m.name | lower }}_amend_1} /public_ip "3.3.3.3" |
Kailash Khalasi | 499430a | 2018-08-20 10:06:07 -0700 | [diff] [blame] | 162 | {% endif %} |
Kailash | eeb2032 | 2018-11-02 10:17:22 -0700 | [diff] [blame] | 163 | {% if m.name == "RCORDIpAddress" -%} |
| 164 | ${json_{{ m.name | lower}}_1}= Set Json Value ${json_{{ m.name | lower }}_1} /ip "2.2.2.2" |
| 165 | ${json_{{ m.name | lower}}_amend_1}= Set Json Value ${json_{{ m.name | lower }}_amend_1} /ip "3.3.3.3" |
| 166 | {% endif %} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 167 | ${json_{{ m.name | lower }}_1}= To JSON ${json_{{ m.name | lower }}_1} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 168 | ${json_{{ m.name | lower }}_amend_1}= To JSON ${json_{{ m.name | lower }}_amend_1} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 169 | Set Suite Variable ${json_{{ m.name | lower }}_1} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 170 | Set Suite Variable ${json_{{ m.name | lower }}_amend_1} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 171 | {% endif -%} |
| 172 | {% endfor %} |
| 173 | |
| 174 | {% for m in proto.messages %} |
| 175 | {%- if m.name not in ['XOSBase'] -%} |
| 176 | Create {{ m.name }} |
| 177 | ##Creating {{ m.name | lower }} object |
| 178 | ${json_{{ m.name | lower }}_tmp}= Set Variable { } |
| 179 | # set required fields for {{ m.name | lower }} object |
| 180 | {% for f in m.fields + xproto_base_fields(m, proto.message_table) -%} |
| 181 | {% if f.link -%} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 182 | {% if f.modifier == "required" and f.options.blank != "True"-%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 183 | # create dependent {{ f.options.model }} |
| 184 | ${dependent_{{ f.options.model | lower }}_id}= Create {{ f.options.model }} |
| 185 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }}_id ${dependent_{{ f.options.model | lower }}_id} |
| 186 | {% endif -%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 187 | {% else -%} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 188 | {% if f.modifier == "required" and f.options.blank != "True"-%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 189 | {% if not f.options.default -%} |
Kailash Khalasi | fc74e1c | 2018-08-10 10:50:40 -0700 | [diff] [blame] | 190 | {% if m.name == "User" and f.name == "email" -%} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 191 | ${json_user_email_tmp}= Generate Random Value {{ f.type }} |
Kailash Khalasi | fc74e1c | 2018-08-10 10:50:40 -0700 | [diff] [blame] | 192 | ${json_user_email_tmp}= Catenate SEPARATOR= ${json_user_email_tmp} @opencord.org |
| 193 | ${json_user_tmp}= Set Json Value ${json_user_tmp} /email "${json_user_email_tmp}" |
| 194 | {% else -%} |
Kailash Khalasi | cceec83 | 2018-08-10 15:46:50 -0700 | [diff] [blame] | 195 | {% if f.name == "created" or f.name == "amend" or f.name =="expires" or f.name =='granted' -%} |
| 196 | ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value float |
| 197 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}" |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 198 | {% elif f.name == "role" -%} |
| 199 | ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value role |
| 200 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}" |
| 201 | {% elif f.name == "direction" -%} |
| 202 | ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value direction |
| 203 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}" |
| 204 | {% elif f.name == "flavor" -%} |
| 205 | ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value flavor |
| 206 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}" |
Kailash Khalasi | 01f410f | 2018-10-12 11:54:19 -0700 | [diff] [blame] | 207 | {% elif f.name == "s_tag" and m.name == "BNGPortMapping" -%} |
Kailash Khalasi | b987e9b | 2018-10-11 11:12:35 -0700 | [diff] [blame] | 208 | ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value vlan_tag |
| 209 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}" |
Kailash Khalasi | cceec83 | 2018-08-10 15:46:50 -0700 | [diff] [blame] | 210 | {% else -%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 211 | ${json_{{ m.name | lower}}_{{ f.name }}_tmp}= Generate Random Value {{ f.type }} |
| 212 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /{{ f.name }} "${json_{{ m.name | lower}}_{{ f.name }}_tmp}" |
| 213 | {% endif -%} |
| 214 | {% endif -%} |
| 215 | {% endif -%} |
| 216 | {% endif -%} |
Kailash Khalasi | fc74e1c | 2018-08-10 10:50:40 -0700 | [diff] [blame] | 217 | {% endif -%} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 218 | {% endfor -%} |
| 219 | {% if m.name == "Site" -%} |
| 220 | ${json_{{ m.name | lower}}_login_base_tmp}= Set Variable testloginbase |
| 221 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /login_base "${json_{{ m.name | lower }}_login_base_tmp}" |
Kailash Khalasi | 78f2a34 | 2018-08-23 10:50:21 -0700 | [diff] [blame] | 222 | {% endif %} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 223 | {% if m.name == "Flavor" -%} |
| 224 | ${json_{{ m.name | lower}}_flavor_tmp}= Set Variable m1.small |
| 225 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /flavor "${json_{{ m.name | lower }}_flavor_tmp}" |
Kailash Khalasi | 0e2bb70 | 2018-08-23 14:46:16 -0700 | [diff] [blame] | 226 | {% endif %} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 227 | {% if m.name == "ServiceGraphConstraint" -%} |
| 228 | ${json_{{ m.name | lower}}_contraints_tmp}= Generate Random Value string |
| 229 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /contraints "${json_{{ m.name | lower }}_contraints_tmp}" |
Kailash Khalasi | 0e2bb70 | 2018-08-23 14:46:16 -0700 | [diff] [blame] | 230 | {% endif %} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 231 | {% if m.name == "Slice" -%} |
| 232 | ${json_{{ m.name | lower}}_name}= Generate Random Slice Name |
| 233 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /name "${json_{{ m.name | lower }}_name}" |
| 234 | {% endif -%} |
| 235 | {% if m.name == "Network" -%} |
| 236 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /permit_all_slices true |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 237 | {% endif %} |
Kailash | c911307 | 2018-11-02 09:15:17 -0700 | [diff] [blame] | 238 | {% if m.name == "RCORDSubscriber" -%} |
| 239 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /owner_id ${rcord_tmp_service_id} |
| 240 | {% endif %} |
Kailash Khalasi | 3481f1e | 2018-09-27 09:13:47 -0700 | [diff] [blame] | 241 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /no_policy true |
| 242 | ${json_{{ m.name | lower}}_tmp}= Set Json Value ${json_{{ m.name | lower }}_tmp} /no_sync true |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 243 | ${json_{{ m.name | lower }}_tmp}= To JSON ${json_{{ m.name | lower }}_tmp} |
Kailash Khalasi | 9302c18 | 2018-05-07 13:46:15 -0600 | [diff] [blame] | 244 | ${resp}= CORD Post /xosapi/v1/{{ xproto_unquote(m.options.app_label) }}/{{ xproto_pluralize(m) | lower}} ${json_{{ m.name | lower }}_tmp} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 245 | ${id_{{ m.name | lower }}_tmp}= Get Json Value ${resp.content} /id |
| 246 | Append To List ${dependent_{{ m.name | lower }}_ids} ${id_{{ m.name | lower }}_tmp} |
| 247 | [Return] ${id_{{ m.name | lower }}_tmp} |
Kailash Khalasi | 96dd899 | 2018-08-28 10:52:31 -0700 | [diff] [blame] | 248 | {% endif %} |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 249 | {% endfor -%} |
| 250 | |
| 251 | Setup Tests |
| 252 | [Documentation] Find all dependent objects per model and create them and store them for later use |
| 253 | {% for m in proto.messages %} |
| 254 | {%- if m.name not in ['XOSBase'] -%} |
| 255 | ${model}= Set Variable {{ m.name | lower }}s |
| 256 | @{dependent_{{ m.name | lower }}_ids}= Create List ${model} |
| 257 | Set Suite Variable @{dependent_{{ m.name | lower }}_ids} |
| 258 | {% endif -%} |
| 259 | {% endfor -%} |
| 260 | @{dependent_models}= Create List |
| 261 | Set Suite Variable ${dependent_models} |
| 262 | ${auth} = Create List ${XOS_USER} ${XOS_PASSWD} |
| 263 | ${HEADERS} Create Dictionary Content-Type=application/json |
| 264 | Create Session ${SERVER_IP} http://${SERVER_IP}:${SERVER_PORT} auth=${AUTH} headers=${HEADERS} |
| 265 | Generate JSON Data |
| 266 | |
| 267 | Teardown Tests |
| 268 | [Documentation] Delete all dependent objects created in Setup |
| 269 | {% for m in proto.messages %} |
| 270 | {%- if m.name not in ['XOSBase'] -%} |
| 271 | ${len}= Get Length ${dependent_{{ m.name | lower }}_ids} |
| 272 | : FOR ${INDEX} IN RANGE 1 ${len} |
| 273 | \ Run Keyword And Ignore Error CORD Delete /xosapi/v1/{{ xproto_unquote(m.options.app_label) }}/${dependent_{{ m.name | lower }}_ids[0]} ${dependent_{{ m.name | lower }}_ids[${INDEX}]} |
| 274 | {% endif -%} |
| 275 | {% endfor -%} |
Kailash Khalasi | 2e0e3e1 | 2018-07-30 08:23:04 -0700 | [diff] [blame] | 276 | Delete All Sessions |