Debian Codegraph @

src/tests/call_json_switches.py

raw symbols SCIP
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 # from pyvesync.devices import vesyncswitch
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": { # V1
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": { # V1
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 # class SwitchDetails:
65 # details_ws = (
66 # {
67 # 'code': 0,
68 # 'msg': None,
69 # 'deviceStatus': 'on',
70 # 'connectionStatus': 'online',
71 # 'activeTime': Defaults.active_time,
72 # 'power': 'None',
73 # 'voltage': 'None',
74 # },
75 # 200,
76 # )
77 # details_eswd16 = ({
78 # "code": 0,
79 # "msg": "请求成功",
80 # "traceId": Defaults.trace_id,
81 # "indicatorlightStatus": "on",
82 # "timer": None,
83 # "schedule": None,
84 # "brightness": "100",
85 # "startMode": None,
86 # "activeTime": Defaults.active_time,
87 # "rgbStatus": "on",
88 # "rgbValue": {
89 # "red": Defaults.color.rgb.red,
90 # "blue": Defaults.color.rgb.blue,
91 # "green": Defaults.color.rgb.green
92 # },
93 # "connectionStatus": "online",
94 # "devicename": Defaults.name('ESWD16'),
95 # "deviceStatus": "on"
96 # }, 200)
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 }