Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Suite Setup |
| 3 | Suite Teardown Delete All Sessions |
| 4 | Test Timeout |
| 5 | Library demjson |
| 6 | Resource Rule-Keywords.robot |
| 7 | |
| 8 | *** Test Cases *** |
| 9 | add_valid_rule |
| 10 | [Documentation] Add a valid rule. |
Guangrong Fu | f830d75 | 2017-10-12 10:00:28 +0800 | [diff] [blame] | 11 | ${dict2} create dictionary rulename=youbowu0314 description=create a new rule! content=package rule03140002 enabled=1 loopcontrolname=closedControlLoop |
Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 12 | ${jsonParams} encode ${dict2} |
| 13 | ${response} createRule ${jsonParams} |
| 14 | ${respJson} to json ${response.content} |
| 15 | ${RULEID} get from dictionary ${respJson} ruleid |
| 16 | set global variable ${RULEID} |
| 17 | log ${RULEID} |
| 18 | |
| 19 | add_invalid_content_rule |
| 20 | [Documentation] Add an invalid rule of which the content is incorrect!! |
| 21 | ${dict1} create dictionary rulename=gy0307001 description=create a new rule! content=123123123 enabled=1 |
| 22 | ${jsonParams} encode ${dict1} |
| 23 | ${response} createRule ${jsonParams} -1 |
| 24 | log ${response.content} |
| 25 | |
| 26 | add_deficient_rule |
| 27 | [Documentation] Add an invalid rule of which some mandatory fields are missing.(rulename) |
| 28 | ${dict3} create dictionary description=create a valid rule! content=package rule2017 enabled=1 |
| 29 | ${jsonParams} encode ${dict3} |
| 30 | ${response} createRule ${jsonParams} -1 |
| 31 | |
| 32 | query_rule_with_existing_id |
| 33 | [Documentation] Query a rule with an existing ID. |
| 34 | should not be empty ${RULEID} |
| 35 | ${response} queryConditionRule {"ruleid":"${RULEID}"} |
| 36 | ${respJson} to json ${response.content} |
| 37 | ${count} get from dictionary ${respJson} totalcount |
| 38 | run keyword if ${count}!=1 fail Can't find the rule with the specified ruleid. |
| 39 | |
| 40 | query_rule_with_non_existing_id |
| 41 | [Documentation] Query a rule with a non-existing ID. |
| 42 | ${response} queryConditionRule {"ruleid":"invalidid"} |
| 43 | ${respJson} to json ${response.content} |
| 44 | ${count} get from dictionary ${respJson} totalcount |
| 45 | run keyword if ${count}!=0 fail |
| 46 | |
| 47 | query_rule_with_partial_existing_name |
| 48 | [Documentation] Query rules with (a part of) an existing name. |
| 49 | ${response} queryConditionRule {"rulename":"youbowu"} |
| 50 | ${respJson} to json ${response.content} |
| 51 | ${count} get from dictionary ${respJson} totalcount |
| 52 | run keyword if ${count}<1 fail Can't find the rule with (a part of) an existing name |
| 53 | |
| 54 | query_rule_with_partial_non_existing_name |
| 55 | [Documentation] Query rules with (a part of) a non-existing name. |
| 56 | ${response} queryConditionRule {"rulename":"zte2017"} |
| 57 | ${respJson} to json ${response.content} |
| 58 | ${count} get from dictionary ${respJson} totalcount |
| 59 | run keyword if ${count}!=0 fail |
| 60 | |
| 61 | query_rule_with_vaild_status |
| 62 | [Documentation] Query rules with a valid status. |
| 63 | ${response} queryConditionRule {"enabled":1} |
| 64 | ${respJson} to json ${response.content} |
| 65 | ${count} get from dictionary ${respJson} totalcount |
| 66 | run keyword if ${count}<0 fail Can't find the rule with the status valued 1. |
| 67 | |
| 68 | query_rule_with_invalid_status |
| 69 | [Documentation] Query rules with an invalid status. |
| 70 | ${response} queryConditionRule {"enabled":99} |
| 71 | ${respJson} to json ${response.content} |
| 72 | ${count} get from dictionary ${respJson} totalcount |
| 73 | run keyword if ${count}!=0 fail |
| 74 | |
| 75 | query_rule_with_empty_status |
| 76 | [Documentation] Query rules with the status left empty. |
| 77 | ${response} queryConditionRule {"enabled":""} |
| 78 | ${respJson} to json ${response.content} |
| 79 | ${count} get from dictionary ${respJson} totalcount |
| 80 | run keyword if ${count}!=0 fail |
| 81 | |
| 82 | query_rule_with_combinational_fields |
| 83 | [Documentation] Query rules using the combination of different fields. |
| 84 | ${dic} create dictionary rulename=youbowu0314 enabled=1 |
| 85 | ${paramJson} encode ${dic} |
| 86 | ${response} queryConditionRule ${paramJson} |
| 87 | ${respJson} to json ${response.content} |
| 88 | ${count} get from dictionary ${respJson} totalcount |
Guangrong Fu | bc08dfd | 2017-10-16 11:16:41 +0800 | [diff] [blame] | 89 | run keyword if ${count}<1 fail Can't find the rules with the combination of different fields. ELSE traversalRuleAttribute ${respJson} |
| 90 | ... ${dic} |
Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 91 | |
| 92 | modify_rule_with_status |
| 93 | [Documentation] modify the rule with a valid status. |
Guangrong Fu | bc08dfd | 2017-10-16 11:16:41 +0800 | [diff] [blame] | 94 | ${dic} create dictionary ruleid=${RULEID} enabled=0 content=package rule03140002 loopcontrolname=closedControlLoop |
Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 95 | ${modifyParam} encode ${dic} |
| 96 | ${modifyResp} modifyRule ${modifyParam} |
| 97 | ${response} queryConditionRule {"ruleid":"${RULEID}"} |
| 98 | ${respJson} to json ${response.content} |
| 99 | ${count} get from dictionary ${respJson} totalcount |
Guangrong Fu | bc08dfd | 2017-10-16 11:16:41 +0800 | [diff] [blame] | 100 | run keyword if ${count}!=1 fail query rule fails! (can't find the rule modified!) ELSE traversalRuleAttribute ${respJson} |
| 101 | ... ${dic} |
Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 102 | |
| 103 | modify_rule_with_invalid_status |
| 104 | [Documentation] modify the rule with an invalid status. |
| 105 | ${dic} create dictionary ruleid=${RULEID} enabled=88 content=package rule03140002 |
| 106 | ${modifyParam} encode ${dic} |
| 107 | ${modifyResponse} modifyRule ${modifyParam} -1 |
| 108 | |
| 109 | modify_rule_with_description |
| 110 | [Documentation] modify the description of the rule with the new string. |
Guangrong Fu | bc08dfd | 2017-10-16 11:16:41 +0800 | [diff] [blame] | 111 | ${dic} create dictionary ruleid=${RULEID} description=now, i modifying the description of the rule. content=package rule03140002 loopcontrolname=closedControlLoop |
Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 112 | ${modifyParam} encode ${dic} |
| 113 | ${modifyResp} modifyRule ${modifyParam} |
| 114 | ${response} queryConditionRule {"ruleid":"${RULEID}"} 1 |
| 115 | ${respJson} to json ${response.content} |
| 116 | ${count} get from dictionary ${respJson} totalcount |
Guangrong Fu | bc08dfd | 2017-10-16 11:16:41 +0800 | [diff] [blame] | 117 | run keyword if ${count}!=1 fail query rule fails! ELSE traversalRuleAttribute ${respJson} |
| 118 | ... ${dic} |
Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 119 | |
| 120 | delete_existing_rule |
| 121 | [Documentation] Delete an existing rule. |
| 122 | should not be empty ${RULEID} |
Guangrong Fu | 80c347b | 2017-09-21 10:00:46 +0800 | [diff] [blame] | 123 | deleteRule ${RULEID} |
Guangrong Fu | 603b27e | 2017-09-04 18:26:10 +0800 | [diff] [blame] | 124 | |
| 125 | delete_non_existing_rule |
| 126 | [Documentation] Delete a non-existing rule. |
Guangrong Fu | 80c347b | 2017-09-21 10:00:46 +0800 | [diff] [blame] | 127 | deleteRule ${RULEID} -1 |