| 1 |
""" |
| 2 |
Switch Device API Responses |
| 3 |
|
| 4 |
SWITCHES variable is a list of device types |
| 5 |
|
| 6 |
DETAILS_RESPONSES variable is a dictionary of responses from the API |
| 7 |
for get_details() methods. The keys are the device types and the |
| 8 |
values are the responses. The responses are tuples of (response, status) |
| 9 |
|
| 10 |
METHOD_RESPONSES variable is a defaultdict of responses from the API. This is |
| 11 |
the FunctionResponse variable from the utils module in the tests dir. |
| 12 |
The default response is a tuple with the value ({"code": 0, "msg": "success"}, 200). |
| 13 |
|
| 14 |
""" |
| 15 |
from copy import deepcopy |
| 16 |
|
| 17 |
from pyvesync.device_map import switch_modules |
| 18 |
from pyvesync.const import DeviceStatus, ConnectionStatus |
| 19 |
from defaults import TestDefaults, FunctionResponsesV1, build_bypass_v1_response |
| 20 |
|
| 21 |
SWITCHES = [m.setup_entry for m in switch_modules] |
| 22 |
SWITCHES_NUM = len(SWITCHES) |
| 23 |
|
| 24 |
|
| 25 |
class SwitchDefaults: |
| 26 |
device_status = DeviceStatus.ON |
| 27 |
connection_status = ConnectionStatus.ONLINE |
| 28 |
indicator_status = DeviceStatus.ON |
| 29 |
rgb_status = DeviceStatus.ON |
| 30 |
|
| 31 |
|
| 32 |
SWITCH_DETAILS: dict[str, dict] = { |
| 33 |
"ESWL01": { |
| 34 |
"deviceStatus": SwitchDefaults.device_status.value, |
| 35 |
"activeTime": TestDefaults.active_time, |
| 36 |
"deviceName": "Etekcity Light Switch", |
| 37 |
"deviceImg": "", |
| 38 |
"connectionStatus": SwitchDefaults.connection_status.value, |
| 39 |
}, |
| 40 |
"ESWL03": { |
| 41 |
"deviceStatus": SwitchDefaults.device_status.value, |
| 42 |
"activeTime": TestDefaults.active_time, |
| 43 |
"deviceName": "Etekcity Light Switch", |
| 44 |
"deviceImg": "", |
| 45 |
"connectionStatus": SwitchDefaults.connection_status.value, |
| 46 |
}, |
| 47 |
"ESWD16": { |
| 48 |
"deviceStatus": SwitchDefaults.device_status.value, |
| 49 |
"activeTime": TestDefaults.active_time, |
| 50 |
"devicename": "Etekcity Dimmer Switch", |
| 51 |
"indicatorlightStatus": SwitchDefaults.indicator_status.value, |
| 52 |
"startMode": None, |
| 53 |
"brightness": TestDefaults.brightness, |
| 54 |
"rgbStatus": SwitchDefaults.rgb_status.value, |
| 55 |
"rgbValue": TestDefaults.color.rgb.to_dict(), |
| 56 |
"timer": None, |
| 57 |
"schedule": None, |
| 58 |
"deviceImg": "https://image.vesync.com/defaultImages/deviceDefaultImages/wifiwalldimmer_240.png", |
| 59 |
"connectionStatus": SwitchDefaults.connection_status.value, |
| 60 |
}, |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
成功", |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
DETAILS_RESPONSES = { |
| 100 |
'ESWL01': build_bypass_v1_response(result_dict=SWITCH_DETAILS['ESWL01']), |
| 101 |
'ESWD16': build_bypass_v1_response(result_dict=SWITCH_DETAILS['ESWD16']), |
| 102 |
'ESWL03': build_bypass_v1_response(result_dict=SWITCH_DETAILS['ESWL03']), |
| 103 |
} |
| 104 |
|
| 105 |
METHOD_RESPONSES = { |
| 106 |
'ESWL01': deepcopy(FunctionResponsesV1), |
| 107 |
'ESWD16': deepcopy(FunctionResponsesV1), |
| 108 |
'ESWL03': deepcopy(FunctionResponsesV1), |
| 109 |
} |