|
35 | 35 | SECOND_LOCAL_ENTITY_ID = "alarm_control_panel.name_1" |
36 | 36 |
|
37 | 37 | CODES_REQUIRED_OPTIONS = {"code_arm_required": True, "code_disarm_required": True} |
| 38 | +CODES_NOT_REQUIRED_OPTIONS = {"code_arm_required": False, "code_disarm_required": False} |
38 | 39 | TEST_RISCO_TO_HA = { |
39 | 40 | "arm": AlarmControlPanelState.ARMED_AWAY, |
40 | 41 | "partial_arm": AlarmControlPanelState.ARMED_HOME, |
@@ -388,7 +389,8 @@ async def test_cloud_sets_full_custom_mapping( |
388 | 389 |
|
389 | 390 |
|
390 | 391 | @pytest.mark.parametrize( |
391 | | - "options", [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}] |
| 392 | + "options", |
| 393 | + [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}], |
392 | 394 | ) |
393 | 395 | async def test_cloud_sets_with_correct_code( |
394 | 396 | hass: HomeAssistant, two_part_cloud_alarm, setup_risco_cloud |
@@ -452,7 +454,58 @@ async def test_cloud_sets_with_correct_code( |
452 | 454 |
|
453 | 455 |
|
454 | 456 | @pytest.mark.parametrize( |
455 | | - "options", [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}] |
| 457 | + "options", |
| 458 | + [{**CUSTOM_MAPPING_OPTIONS, **CODES_NOT_REQUIRED_OPTIONS}], |
| 459 | +) |
| 460 | +async def test_cloud_sets_without_code( |
| 461 | + hass: HomeAssistant, two_part_cloud_alarm, setup_risco_cloud |
| 462 | +) -> None: |
| 463 | + """Test settings the various modes when code is not required.""" |
| 464 | + await _test_cloud_service_call( |
| 465 | + hass, SERVICE_ALARM_DISARM, "disarm", FIRST_CLOUD_ENTITY_ID, 0 |
| 466 | + ) |
| 467 | + await _test_cloud_service_call( |
| 468 | + hass, SERVICE_ALARM_DISARM, "disarm", SECOND_CLOUD_ENTITY_ID, 1 |
| 469 | + ) |
| 470 | + await _test_cloud_service_call( |
| 471 | + hass, SERVICE_ALARM_ARM_AWAY, "arm", FIRST_CLOUD_ENTITY_ID, 0 |
| 472 | + ) |
| 473 | + await _test_cloud_service_call( |
| 474 | + hass, SERVICE_ALARM_ARM_AWAY, "arm", SECOND_CLOUD_ENTITY_ID, 1 |
| 475 | + ) |
| 476 | + await _test_cloud_service_call( |
| 477 | + hass, SERVICE_ALARM_ARM_HOME, "partial_arm", FIRST_CLOUD_ENTITY_ID, 0 |
| 478 | + ) |
| 479 | + await _test_cloud_service_call( |
| 480 | + hass, SERVICE_ALARM_ARM_HOME, "partial_arm", SECOND_CLOUD_ENTITY_ID, 1 |
| 481 | + ) |
| 482 | + await _test_cloud_service_call( |
| 483 | + hass, SERVICE_ALARM_ARM_NIGHT, "group_arm", FIRST_CLOUD_ENTITY_ID, 0, "C" |
| 484 | + ) |
| 485 | + await _test_cloud_service_call( |
| 486 | + hass, SERVICE_ALARM_ARM_NIGHT, "group_arm", SECOND_CLOUD_ENTITY_ID, 1, "C" |
| 487 | + ) |
| 488 | + with pytest.raises(HomeAssistantError): |
| 489 | + await _test_cloud_no_service_call( |
| 490 | + hass, |
| 491 | + SERVICE_ALARM_ARM_CUSTOM_BYPASS, |
| 492 | + "partial_arm", |
| 493 | + FIRST_CLOUD_ENTITY_ID, |
| 494 | + 0, |
| 495 | + ) |
| 496 | + with pytest.raises(HomeAssistantError): |
| 497 | + await _test_cloud_no_service_call( |
| 498 | + hass, |
| 499 | + SERVICE_ALARM_ARM_CUSTOM_BYPASS, |
| 500 | + "partial_arm", |
| 501 | + SECOND_CLOUD_ENTITY_ID, |
| 502 | + 1, |
| 503 | + ) |
| 504 | + |
| 505 | + |
| 506 | +@pytest.mark.parametrize( |
| 507 | + "options", |
| 508 | + [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}], |
456 | 509 | ) |
457 | 510 | async def test_cloud_sets_with_incorrect_code( |
458 | 511 | hass: HomeAssistant, two_part_cloud_alarm, setup_risco_cloud |
@@ -837,7 +890,8 @@ async def test_local_sets_full_custom_mapping( |
837 | 890 |
|
838 | 891 |
|
839 | 892 | @pytest.mark.parametrize( |
840 | | - "options", [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}] |
| 893 | + "options", |
| 894 | + [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}], |
841 | 895 | ) |
842 | 896 | async def test_local_sets_with_correct_code( |
843 | 897 | hass: HomeAssistant, two_part_local_alarm, setup_risco_local |
@@ -931,7 +985,8 @@ async def test_local_sets_with_correct_code( |
931 | 985 |
|
932 | 986 |
|
933 | 987 | @pytest.mark.parametrize( |
934 | | - "options", [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}] |
| 988 | + "options", |
| 989 | + [{**CUSTOM_MAPPING_OPTIONS, **CODES_REQUIRED_OPTIONS}], |
935 | 990 | ) |
936 | 991 | async def test_local_sets_with_incorrect_code( |
937 | 992 | hass: HomeAssistant, two_part_local_alarm, setup_risco_local |
@@ -1020,3 +1075,87 @@ async def test_local_sets_with_incorrect_code( |
1020 | 1075 | two_part_local_alarm[1], |
1021 | 1076 | **code, |
1022 | 1077 | ) |
| 1078 | + |
| 1079 | + |
| 1080 | +@pytest.mark.parametrize( |
| 1081 | + "options", |
| 1082 | + [{**CUSTOM_MAPPING_OPTIONS, **CODES_NOT_REQUIRED_OPTIONS}], |
| 1083 | +) |
| 1084 | +async def test_local_sets_without_code( |
| 1085 | + hass: HomeAssistant, two_part_local_alarm, setup_risco_local |
| 1086 | +) -> None: |
| 1087 | + """Test settings the various modes when code is not required.""" |
| 1088 | + await _test_local_service_call( |
| 1089 | + hass, |
| 1090 | + SERVICE_ALARM_DISARM, |
| 1091 | + "disarm", |
| 1092 | + FIRST_LOCAL_ENTITY_ID, |
| 1093 | + two_part_local_alarm[0], |
| 1094 | + ) |
| 1095 | + await _test_local_service_call( |
| 1096 | + hass, |
| 1097 | + SERVICE_ALARM_DISARM, |
| 1098 | + "disarm", |
| 1099 | + SECOND_LOCAL_ENTITY_ID, |
| 1100 | + two_part_local_alarm[1], |
| 1101 | + ) |
| 1102 | + await _test_local_service_call( |
| 1103 | + hass, |
| 1104 | + SERVICE_ALARM_ARM_AWAY, |
| 1105 | + "arm", |
| 1106 | + FIRST_LOCAL_ENTITY_ID, |
| 1107 | + two_part_local_alarm[0], |
| 1108 | + ) |
| 1109 | + await _test_local_service_call( |
| 1110 | + hass, |
| 1111 | + SERVICE_ALARM_ARM_AWAY, |
| 1112 | + "arm", |
| 1113 | + SECOND_LOCAL_ENTITY_ID, |
| 1114 | + two_part_local_alarm[1], |
| 1115 | + ) |
| 1116 | + await _test_local_service_call( |
| 1117 | + hass, |
| 1118 | + SERVICE_ALARM_ARM_HOME, |
| 1119 | + "partial_arm", |
| 1120 | + FIRST_LOCAL_ENTITY_ID, |
| 1121 | + two_part_local_alarm[0], |
| 1122 | + ) |
| 1123 | + await _test_local_service_call( |
| 1124 | + hass, |
| 1125 | + SERVICE_ALARM_ARM_HOME, |
| 1126 | + "partial_arm", |
| 1127 | + SECOND_LOCAL_ENTITY_ID, |
| 1128 | + two_part_local_alarm[1], |
| 1129 | + ) |
| 1130 | + await _test_local_service_call( |
| 1131 | + hass, |
| 1132 | + SERVICE_ALARM_ARM_NIGHT, |
| 1133 | + "group_arm", |
| 1134 | + FIRST_LOCAL_ENTITY_ID, |
| 1135 | + two_part_local_alarm[0], |
| 1136 | + "C", |
| 1137 | + ) |
| 1138 | + await _test_local_service_call( |
| 1139 | + hass, |
| 1140 | + SERVICE_ALARM_ARM_NIGHT, |
| 1141 | + "group_arm", |
| 1142 | + SECOND_LOCAL_ENTITY_ID, |
| 1143 | + two_part_local_alarm[1], |
| 1144 | + "C", |
| 1145 | + ) |
| 1146 | + with pytest.raises(HomeAssistantError): |
| 1147 | + await _test_local_no_service_call( |
| 1148 | + hass, |
| 1149 | + SERVICE_ALARM_ARM_CUSTOM_BYPASS, |
| 1150 | + "partial_arm", |
| 1151 | + FIRST_LOCAL_ENTITY_ID, |
| 1152 | + two_part_local_alarm[0], |
| 1153 | + ) |
| 1154 | + with pytest.raises(HomeAssistantError): |
| 1155 | + await _test_local_no_service_call( |
| 1156 | + hass, |
| 1157 | + SERVICE_ALARM_ARM_CUSTOM_BYPASS, |
| 1158 | + "partial_arm", |
| 1159 | + SECOND_LOCAL_ENTITY_ID, |
| 1160 | + two_part_local_alarm[1], |
| 1161 | + ) |
0 commit comments