tplinkrouterc6u 4.2.0__tar.gz → 4.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/PKG-INFO +24 -22
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/README.md +22 -21
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/setup.py +3 -2
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/test/test_client.py +76 -60
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/test/test_client_c1200.py +17 -16
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/test/test_client_deco.py +52 -51
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/test/test_client_mr.py +21 -21
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u/client.py +127 -117
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u/dataclass.py +25 -24
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u/encryption.py +15 -15
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u.egg-info/PKG-INFO +24 -22
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/LICENSE +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/setup.cfg +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/test/__init__.py +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u/__init__.py +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u/enum.py +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u/exception.py +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u.egg-info/SOURCES.txt +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u.egg-info/dependency_links.txt +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u.egg-info/requires.txt +0 -0
- {tplinkrouterc6u-4.2.0 → tplinkrouterc6u-4.2.2}/tplinkrouterc6u.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tplinkrouterc6u
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.2
|
|
4
4
|
Summary: TP-Link Router API
|
|
5
5
|
Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
|
|
6
6
|
Author: Alex Erohin
|
|
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
15
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
15
16
|
Requires-Python: >=3.10
|
|
16
17
|
Description-Content-Type: text/markdown
|
|
@@ -228,12 +229,11 @@ or you have TP-link C1200 V2 or similar router you need to get web encrypted pas
|
|
|
228
229
|
- Archer AX12 v1.0
|
|
229
230
|
- Archer AX20 v1.0
|
|
230
231
|
- Archer AX20 v3.0
|
|
231
|
-
- Archer AX21 v1.20
|
|
232
|
+
- Archer AX21 (v1.20, v3.0)
|
|
232
233
|
- Archer AX23 v1.0
|
|
233
234
|
- Archer AX50 v1.0
|
|
234
235
|
- Archer AX53 v2
|
|
235
|
-
- Archer AX55 v1.0
|
|
236
|
-
- Archer AX55 V1.60
|
|
236
|
+
- Archer AX55 (v1.0, V1.60, v4.0)
|
|
237
237
|
- Archer AX72 V1
|
|
238
238
|
- Archer AX73 V1
|
|
239
239
|
- Archer AX75 V1
|
|
@@ -242,31 +242,35 @@ or you have TP-link C1200 V2 or similar router you need to get web encrypted pas
|
|
|
242
242
|
- Archer AX3000 V1
|
|
243
243
|
- Archer AX6000 V1
|
|
244
244
|
- Archer AX11000 V1
|
|
245
|
+
- Archer BE800 v1.0
|
|
245
246
|
- Archer BE805 v1.0
|
|
246
|
-
- Archer C1200 v2.0 (You need to use [web encrypted password](#encrypted_pass))
|
|
247
|
+
- Archer C1200 (v1.0, v2.0) (You need to use [web encrypted password](#encrypted_pass))
|
|
247
248
|
- Archer C2300 v1.0 (You need to use [web encrypted password](#encrypted_pass))
|
|
248
|
-
- Archer C6 v2.0
|
|
249
|
-
- Archer C6 v3.0
|
|
249
|
+
- Archer C6 (v2.0, v3.0)
|
|
250
250
|
- Archer C6U v1.0
|
|
251
|
-
- Archer C7 v5.0
|
|
252
|
-
- Archer
|
|
253
|
-
- Archer
|
|
254
|
-
- Archer
|
|
255
|
-
- Archer MR600 v3
|
|
251
|
+
- Archer C7 (v4.0, v5.0)
|
|
252
|
+
- Archer C5400X V1
|
|
253
|
+
- Archer GX90 v1.0
|
|
254
|
+
- Archer MR200 (v5, v5.3)
|
|
255
|
+
- Archer MR600 (v1, v3)
|
|
256
|
+
- Archer VR2100v v1
|
|
256
257
|
- Archer VR900v
|
|
257
258
|
- Deco M4 2.0
|
|
258
259
|
- Deco M4R 2.0
|
|
259
|
-
- Deco M5
|
|
260
|
+
- Deco M5 v3
|
|
260
261
|
- Deco M9 Pro
|
|
262
|
+
- Deco M9 Plus 1.0
|
|
261
263
|
- Deco P7
|
|
262
|
-
- Deco X20
|
|
263
|
-
- Deco
|
|
264
|
+
- Deco X20
|
|
265
|
+
- Deco X50 v1.3
|
|
266
|
+
- Deco X60 V3
|
|
264
267
|
- Deco X90
|
|
265
|
-
- Deco XE75
|
|
266
|
-
-
|
|
268
|
+
- Deco XE75 (v1.0, v2.0)
|
|
269
|
+
- TD-W9960 (v1, V1.20)
|
|
270
|
+
- TL-MR100 v2.0
|
|
267
271
|
- TL-MR105
|
|
268
|
-
- TL-MR6400 v5
|
|
269
|
-
- TL-
|
|
272
|
+
- TL-MR6400 (v5, v5.3)
|
|
273
|
+
- TL-WA3001 v1.0
|
|
270
274
|
|
|
271
275
|
### Not fully tested Hardware Versions
|
|
272
276
|
- AD7200 V2
|
|
@@ -282,11 +286,9 @@ or you have TP-link C1200 V2 or similar router you need to get web encrypted pas
|
|
|
282
286
|
- Archer C900 V1
|
|
283
287
|
- Archer C1200 V3
|
|
284
288
|
- Archer C1900 V2
|
|
285
|
-
- Archer C2300
|
|
289
|
+
- Archer C2300 V2
|
|
286
290
|
- Archer C4000 (V2 and V3)
|
|
287
291
|
- Archer C5400 V2
|
|
288
|
-
- Archer C5400X V1
|
|
289
|
-
- TD-W9960 v1
|
|
290
292
|
- TL-WR1043N V5
|
|
291
293
|
|
|
292
294
|
Please let me know if you have tested integration with one of this or other model. Open an issue with info about router's model, hardware and firmware versions.
|
|
@@ -207,12 +207,11 @@ or you have TP-link C1200 V2 or similar router you need to get web encrypted pas
|
|
|
207
207
|
- Archer AX12 v1.0
|
|
208
208
|
- Archer AX20 v1.0
|
|
209
209
|
- Archer AX20 v3.0
|
|
210
|
-
- Archer AX21 v1.20
|
|
210
|
+
- Archer AX21 (v1.20, v3.0)
|
|
211
211
|
- Archer AX23 v1.0
|
|
212
212
|
- Archer AX50 v1.0
|
|
213
213
|
- Archer AX53 v2
|
|
214
|
-
- Archer AX55 v1.0
|
|
215
|
-
- Archer AX55 V1.60
|
|
214
|
+
- Archer AX55 (v1.0, V1.60, v4.0)
|
|
216
215
|
- Archer AX72 V1
|
|
217
216
|
- Archer AX73 V1
|
|
218
217
|
- Archer AX75 V1
|
|
@@ -221,31 +220,35 @@ or you have TP-link C1200 V2 or similar router you need to get web encrypted pas
|
|
|
221
220
|
- Archer AX3000 V1
|
|
222
221
|
- Archer AX6000 V1
|
|
223
222
|
- Archer AX11000 V1
|
|
223
|
+
- Archer BE800 v1.0
|
|
224
224
|
- Archer BE805 v1.0
|
|
225
|
-
- Archer C1200 v2.0 (You need to use [web encrypted password](#encrypted_pass))
|
|
225
|
+
- Archer C1200 (v1.0, v2.0) (You need to use [web encrypted password](#encrypted_pass))
|
|
226
226
|
- Archer C2300 v1.0 (You need to use [web encrypted password](#encrypted_pass))
|
|
227
|
-
- Archer C6 v2.0
|
|
228
|
-
- Archer C6 v3.0
|
|
227
|
+
- Archer C6 (v2.0, v3.0)
|
|
229
228
|
- Archer C6U v1.0
|
|
230
|
-
- Archer C7 v5.0
|
|
231
|
-
- Archer
|
|
232
|
-
- Archer
|
|
233
|
-
- Archer
|
|
234
|
-
- Archer MR600 v3
|
|
229
|
+
- Archer C7 (v4.0, v5.0)
|
|
230
|
+
- Archer C5400X V1
|
|
231
|
+
- Archer GX90 v1.0
|
|
232
|
+
- Archer MR200 (v5, v5.3)
|
|
233
|
+
- Archer MR600 (v1, v3)
|
|
234
|
+
- Archer VR2100v v1
|
|
235
235
|
- Archer VR900v
|
|
236
236
|
- Deco M4 2.0
|
|
237
237
|
- Deco M4R 2.0
|
|
238
|
-
- Deco M5
|
|
238
|
+
- Deco M5 v3
|
|
239
239
|
- Deco M9 Pro
|
|
240
|
+
- Deco M9 Plus 1.0
|
|
240
241
|
- Deco P7
|
|
241
|
-
- Deco X20
|
|
242
|
-
- Deco
|
|
242
|
+
- Deco X20
|
|
243
|
+
- Deco X50 v1.3
|
|
244
|
+
- Deco X60 V3
|
|
243
245
|
- Deco X90
|
|
244
|
-
- Deco XE75
|
|
245
|
-
-
|
|
246
|
+
- Deco XE75 (v1.0, v2.0)
|
|
247
|
+
- TD-W9960 (v1, V1.20)
|
|
248
|
+
- TL-MR100 v2.0
|
|
246
249
|
- TL-MR105
|
|
247
|
-
- TL-MR6400 v5
|
|
248
|
-
- TL-
|
|
250
|
+
- TL-MR6400 (v5, v5.3)
|
|
251
|
+
- TL-WA3001 v1.0
|
|
249
252
|
|
|
250
253
|
### Not fully tested Hardware Versions
|
|
251
254
|
- AD7200 V2
|
|
@@ -261,11 +264,9 @@ or you have TP-link C1200 V2 or similar router you need to get web encrypted pas
|
|
|
261
264
|
- Archer C900 V1
|
|
262
265
|
- Archer C1200 V3
|
|
263
266
|
- Archer C1900 V2
|
|
264
|
-
- Archer C2300
|
|
267
|
+
- Archer C2300 V2
|
|
265
268
|
- Archer C4000 (V2 and V3)
|
|
266
269
|
- Archer C5400 V2
|
|
267
|
-
- Archer C5400X V1
|
|
268
|
-
- TD-W9960 v1
|
|
269
270
|
- TL-WR1043N V5
|
|
270
271
|
|
|
271
272
|
Please let me know if you have tested integration with one of this or other model. Open an issue with info about router's model, hardware and firmware versions.
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="tplinkrouterc6u",
|
|
8
|
-
version="4.2.
|
|
8
|
+
version="4.2.2",
|
|
9
9
|
author="Alex Erohin",
|
|
10
10
|
author_email="alexanderErohin@yandex.ru",
|
|
11
11
|
description="TP-Link Router API",
|
|
@@ -20,8 +20,9 @@ setuptools.setup(
|
|
|
20
20
|
"Programming Language :: Python :: 3.10",
|
|
21
21
|
"Programming Language :: Python :: 3.11",
|
|
22
22
|
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
23
24
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
24
25
|
],
|
|
25
26
|
install_requires=['requests', 'pycryptodome', 'macaddress'],
|
|
26
27
|
python_requires='>=3.10',
|
|
27
|
-
)
|
|
28
|
+
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
from unittest import main, TestCase
|
|
2
|
+
from macaddress import EUI48
|
|
3
|
+
from ipaddress import IPv4Address
|
|
4
|
+
from json import loads
|
|
5
5
|
from tplinkrouterc6u import (
|
|
6
6
|
TplinkRouter,
|
|
7
7
|
Connection,
|
|
@@ -11,7 +11,7 @@ from tplinkrouterc6u import (
|
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class TestTPLinkClient(
|
|
14
|
+
class TestTPLinkClient(TestCase):
|
|
15
15
|
def test_get_status(self) -> None:
|
|
16
16
|
response_status = '''
|
|
17
17
|
{
|
|
@@ -53,6 +53,12 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
53
53
|
"macaddr": "06:82:9d:2b:8f:c6",
|
|
54
54
|
"ipaddr": "192.168.1.186",
|
|
55
55
|
"hostname": "UNKNOWN"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"wire_type": "2.4G",
|
|
59
|
+
"macaddr": "06:55:9d:2b:8f:a7",
|
|
60
|
+
"ipaddr": "Unknown",
|
|
61
|
+
"hostname": "Unknown"
|
|
56
62
|
}
|
|
57
63
|
],
|
|
58
64
|
"guest_5g_psk_key": "",
|
|
@@ -206,9 +212,9 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
206
212
|
def request(self, path: str, data: str,
|
|
207
213
|
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
208
214
|
if path == 'admin/status?form=all&operation=read':
|
|
209
|
-
return
|
|
215
|
+
return loads(response_status)['data']
|
|
210
216
|
elif path == 'admin/wireless?form=statistics':
|
|
211
|
-
return
|
|
217
|
+
return loads(response_stats)['data']
|
|
212
218
|
raise ClientException()
|
|
213
219
|
|
|
214
220
|
client = TPLinkRouterTest('', '')
|
|
@@ -216,18 +222,18 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
216
222
|
|
|
217
223
|
self.assertIsInstance(status, Status)
|
|
218
224
|
self.assertEqual(status.wan_macaddr, 'D6-0B-40-57-DA-60')
|
|
219
|
-
self.assertIsInstance(status.wan_macaddress,
|
|
225
|
+
self.assertIsInstance(status.wan_macaddress, EUI48)
|
|
220
226
|
self.assertEqual(status.lan_macaddr, '06-E6-97-9E-23-F5')
|
|
221
|
-
self.assertIsInstance(status.lan_macaddress,
|
|
227
|
+
self.assertIsInstance(status.lan_macaddress, EUI48)
|
|
222
228
|
self.assertEqual(status.wan_ipv4_addr, '192.168.1.100')
|
|
223
|
-
self.assertIsInstance(status.lan_ipv4_address,
|
|
229
|
+
self.assertIsInstance(status.lan_ipv4_address, IPv4Address)
|
|
224
230
|
self.assertEqual(status.lan_ipv4_addr, '192.168.1.100')
|
|
225
231
|
self.assertEqual(status.wan_ipv4_gateway, '192.168.1.254')
|
|
226
|
-
self.assertIsInstance(status.wan_ipv4_address,
|
|
232
|
+
self.assertIsInstance(status.wan_ipv4_address, IPv4Address)
|
|
227
233
|
self.assertEqual(status.wired_total, 2)
|
|
228
|
-
self.assertEqual(status.wifi_clients_total,
|
|
234
|
+
self.assertEqual(status.wifi_clients_total, 3)
|
|
229
235
|
self.assertEqual(status.guest_clients_total, 0)
|
|
230
|
-
self.assertEqual(status.clients_total,
|
|
236
|
+
self.assertEqual(status.clients_total, 5)
|
|
231
237
|
self.assertEqual(status.iot_clients_total, None)
|
|
232
238
|
self.assertEqual(status.guest_2g_enable, False)
|
|
233
239
|
self.assertEqual(status.guest_5g_enable, False)
|
|
@@ -238,22 +244,22 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
238
244
|
self.assertEqual(status.wan_ipv4_uptime, None)
|
|
239
245
|
self.assertEqual(status.mem_usage, 0.43)
|
|
240
246
|
self.assertEqual(status.cpu_usage, 0.28)
|
|
241
|
-
self.assertEqual(len(status.devices),
|
|
247
|
+
self.assertEqual(len(status.devices), 5)
|
|
242
248
|
self.assertIsInstance(status.devices[0], Device)
|
|
243
249
|
self.assertEqual(status.devices[0].type, Connection.WIRED)
|
|
244
250
|
self.assertEqual(status.devices[0].macaddr, '3D-24-25-24-30-79')
|
|
245
|
-
self.assertIsInstance(status.devices[0].macaddress,
|
|
251
|
+
self.assertIsInstance(status.devices[0].macaddress, EUI48)
|
|
246
252
|
self.assertEqual(status.devices[0].ipaddr, '192.168.1.228')
|
|
247
|
-
self.assertIsInstance(status.devices[0].ipaddress,
|
|
253
|
+
self.assertIsInstance(status.devices[0].ipaddress, IPv4Address)
|
|
248
254
|
self.assertEqual(status.devices[0].hostname, 'SERVER')
|
|
249
255
|
self.assertEqual(status.devices[0].packets_sent, None)
|
|
250
256
|
self.assertEqual(status.devices[0].packets_received, None)
|
|
251
257
|
self.assertIsInstance(status.devices[0], Device)
|
|
252
258
|
self.assertEqual(status.devices[1].type, Connection.WIRED)
|
|
253
259
|
self.assertEqual(status.devices[1].macaddr, 'AC-04-D6-25-2A-96')
|
|
254
|
-
self.assertIsInstance(status.devices[1].macaddress,
|
|
260
|
+
self.assertIsInstance(status.devices[1].macaddress, EUI48)
|
|
255
261
|
self.assertEqual(status.devices[1].ipaddr, '192.168.1.254')
|
|
256
|
-
self.assertIsInstance(status.devices[1].ipaddress,
|
|
262
|
+
self.assertIsInstance(status.devices[1].ipaddress, IPv4Address)
|
|
257
263
|
self.assertEqual(status.devices[1].hostname, 'UNKNOWN')
|
|
258
264
|
self.assertEqual(status.devices[1].packets_sent, None)
|
|
259
265
|
self.assertEqual(status.devices[1].packets_received, None)
|
|
@@ -265,12 +271,19 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
265
271
|
self.assertEqual(status.devices[2].packets_sent, 450333)
|
|
266
272
|
self.assertEqual(status.devices[2].packets_received, 4867482)
|
|
267
273
|
self.assertIsInstance(status.devices[3], Device)
|
|
268
|
-
self.assertEqual(status.devices[3].type, Connection.
|
|
269
|
-
self.assertEqual(status.devices[3].macaddr, '
|
|
274
|
+
self.assertEqual(status.devices[3].type, Connection.HOST_2G)
|
|
275
|
+
self.assertEqual(status.devices[3].macaddr, '06-55-9D-2B-8F-A7')
|
|
270
276
|
self.assertEqual(status.devices[3].ipaddr, '0.0.0.0')
|
|
271
|
-
self.assertEqual(status.devices[3].hostname, '')
|
|
272
|
-
self.assertEqual(status.devices[3].packets_sent,
|
|
273
|
-
self.assertEqual(status.devices[3].packets_received,
|
|
277
|
+
self.assertEqual(status.devices[3].hostname, 'Unknown')
|
|
278
|
+
self.assertEqual(status.devices[3].packets_sent, None)
|
|
279
|
+
self.assertEqual(status.devices[3].packets_received, None)
|
|
280
|
+
self.assertIsInstance(status.devices[4], Device)
|
|
281
|
+
self.assertEqual(status.devices[4].type, Connection.HOST_5G)
|
|
282
|
+
self.assertEqual(status.devices[4].macaddr, '1F-7A-BD-F7-20-0D')
|
|
283
|
+
self.assertEqual(status.devices[4].ipaddr, '0.0.0.0')
|
|
284
|
+
self.assertEqual(status.devices[4].hostname, '')
|
|
285
|
+
self.assertEqual(status.devices[4].packets_sent, 134815)
|
|
286
|
+
self.assertEqual(status.devices[4].packets_received, 2953078)
|
|
274
287
|
|
|
275
288
|
def test_get_status_ax_55(self) -> None:
|
|
276
289
|
response_status = '''
|
|
@@ -321,9 +334,9 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
321
334
|
def request(self, path: str, data: str,
|
|
322
335
|
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
323
336
|
if path == 'admin/status?form=all&operation=read':
|
|
324
|
-
return
|
|
337
|
+
return loads(response_status)['data']
|
|
325
338
|
elif path == 'admin/wireless?form=statistics':
|
|
326
|
-
return
|
|
339
|
+
return loads(response_stats)['data']
|
|
327
340
|
raise ClientException()
|
|
328
341
|
|
|
329
342
|
client = TPLinkRouterTest('', '')
|
|
@@ -332,7 +345,7 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
332
345
|
self.assertIsInstance(status, Status)
|
|
333
346
|
self.assertEqual(status.wan_macaddr, None)
|
|
334
347
|
self.assertEqual(status.lan_macaddr, '06-E6-97-9E-23-F5')
|
|
335
|
-
self.assertIsInstance(status.lan_macaddress,
|
|
348
|
+
self.assertIsInstance(status.lan_macaddress, EUI48)
|
|
336
349
|
self.assertEqual(status.wan_ipv4_addr, None)
|
|
337
350
|
self.assertEqual(status.lan_ipv4_addr, None)
|
|
338
351
|
self.assertEqual(status.wan_ipv4_gateway, None)
|
|
@@ -357,27 +370,27 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
357
370
|
self.assertIsInstance(status.devices[0], Device)
|
|
358
371
|
self.assertEqual(status.devices[0].type, Connection.WIRED)
|
|
359
372
|
self.assertEqual(status.devices[0].macaddr, '3D-24-25-24-30-79')
|
|
360
|
-
self.assertIsInstance(status.devices[0].macaddress,
|
|
373
|
+
self.assertIsInstance(status.devices[0].macaddress, EUI48)
|
|
361
374
|
self.assertEqual(status.devices[0].ipaddr, '192.168.1.228')
|
|
362
|
-
self.assertIsInstance(status.devices[0].ipaddress,
|
|
375
|
+
self.assertIsInstance(status.devices[0].ipaddress, IPv4Address)
|
|
363
376
|
self.assertEqual(status.devices[0].hostname, 'SERVER')
|
|
364
377
|
self.assertEqual(status.devices[0].packets_sent, None)
|
|
365
378
|
self.assertEqual(status.devices[0].packets_received, None)
|
|
366
379
|
self.assertIsInstance(status.devices[1], Device)
|
|
367
380
|
self.assertEqual(status.devices[1].type, Connection.WIRED)
|
|
368
381
|
self.assertEqual(status.devices[1].macaddr, 'AC-04-D6-25-2A-96')
|
|
369
|
-
self.assertIsInstance(status.devices[1].macaddress,
|
|
382
|
+
self.assertIsInstance(status.devices[1].macaddress, EUI48)
|
|
370
383
|
self.assertEqual(status.devices[1].ipaddr, '192.168.1.254')
|
|
371
|
-
self.assertIsInstance(status.devices[1].ipaddress,
|
|
384
|
+
self.assertIsInstance(status.devices[1].ipaddress, IPv4Address)
|
|
372
385
|
self.assertEqual(status.devices[1].hostname, 'UNKNOWN')
|
|
373
386
|
self.assertEqual(status.devices[1].packets_sent, None)
|
|
374
387
|
self.assertEqual(status.devices[1].packets_received, None)
|
|
375
388
|
self.assertIsInstance(status.devices[2], Device)
|
|
376
389
|
self.assertEqual(status.devices[2].type, Connection.HOST_2G)
|
|
377
390
|
self.assertEqual(status.devices[2].macaddr, '06-82-9D-2B-8F-C6')
|
|
378
|
-
self.assertIsInstance(status.devices[2].macaddress,
|
|
391
|
+
self.assertIsInstance(status.devices[2].macaddress, EUI48)
|
|
379
392
|
self.assertEqual(status.devices[2].ipaddr, '192.168.1.186')
|
|
380
|
-
self.assertIsInstance(status.devices[2].ipaddress,
|
|
393
|
+
self.assertIsInstance(status.devices[2].ipaddress, IPv4Address)
|
|
381
394
|
self.assertEqual(status.devices[2].hostname, 'UNKNOWN')
|
|
382
395
|
self.assertEqual(status.devices[2].packets_sent, None)
|
|
383
396
|
self.assertEqual(status.devices[2].packets_received, None)
|
|
@@ -425,11 +438,14 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
425
438
|
response_game_accelerator = '''
|
|
426
439
|
{
|
|
427
440
|
"data": [
|
|
428
|
-
{"mac": "06:82:9d:2b:8f:c6", "deviceTag":"2.4G", "isGuest":false, "ip":"192.168.1.186",
|
|
429
|
-
"uploadSpeed":12, "downloadSpeed":77},
|
|
430
|
-
{"mac": "fb:90:b8:2a:8a:b1", "deviceTag":"iot_2.4G", "isGuest":false, "ip":"192.168.1.187",
|
|
431
|
-
|
|
432
|
-
{"mac": "
|
|
441
|
+
{"mac": "06:82:9d:2b:8f:c6", "deviceTag":"2.4G", "isGuest":false, "ip":"192.168.1.186",
|
|
442
|
+
"deviceName":"name1", "uploadSpeed":12, "downloadSpeed":77},
|
|
443
|
+
{"mac": "fb:90:b8:2a:8a:b1", "deviceTag":"iot_2.4G", "isGuest":false, "ip":"192.168.1.187",
|
|
444
|
+
"deviceName":"name2"},
|
|
445
|
+
{"mac": "54:b3:a2:f7:be:ea", "deviceTag":"iot_5G", "isGuest":false, "ip":"192.168.1.188",
|
|
446
|
+
"deviceName":"name3"},
|
|
447
|
+
{"mac": "3c:ae:e1:83:94:9d", "deviceTag":"iot_6G", "isGuest":false, "ip":"192.168.1.189",
|
|
448
|
+
"deviceName":"name4"}
|
|
433
449
|
],
|
|
434
450
|
"timeout": false,
|
|
435
451
|
"success": true
|
|
@@ -463,11 +479,11 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
463
479
|
def request(self, path: str, data: str,
|
|
464
480
|
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
465
481
|
if path == 'admin/status?form=all&operation=read':
|
|
466
|
-
return
|
|
482
|
+
return loads(response_status)['data']
|
|
467
483
|
elif path == 'admin/smart_network?form=game_accelerator':
|
|
468
|
-
return
|
|
484
|
+
return loads(response_game_accelerator)['data']
|
|
469
485
|
elif path == 'admin/wireless?form=statistics':
|
|
470
|
-
return
|
|
486
|
+
return loads(response_stats)['data']
|
|
471
487
|
raise ClientException()
|
|
472
488
|
|
|
473
489
|
client = TPLinkRouterTest('', '')
|
|
@@ -476,7 +492,7 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
476
492
|
self.assertIsInstance(status, Status)
|
|
477
493
|
self.assertEqual(status.wan_macaddr, None)
|
|
478
494
|
self.assertEqual(status.lan_macaddr, '06-E6-97-9E-23-F5')
|
|
479
|
-
self.assertIsInstance(status.lan_macaddress,
|
|
495
|
+
self.assertIsInstance(status.lan_macaddress, EUI48)
|
|
480
496
|
self.assertEqual(status.wan_ipv4_addr, None)
|
|
481
497
|
self.assertEqual(status.lan_ipv4_addr, None)
|
|
482
498
|
self.assertEqual(status.wan_ipv4_gateway, None)
|
|
@@ -501,27 +517,27 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
501
517
|
self.assertIsInstance(status.devices[0], Device)
|
|
502
518
|
self.assertEqual(status.devices[0].type, Connection.WIRED)
|
|
503
519
|
self.assertEqual(status.devices[0].macaddr, '3D-24-25-24-30-79')
|
|
504
|
-
self.assertIsInstance(status.devices[0].macaddress,
|
|
520
|
+
self.assertIsInstance(status.devices[0].macaddress, EUI48)
|
|
505
521
|
self.assertEqual(status.devices[0].ipaddr, '192.168.1.228')
|
|
506
|
-
self.assertIsInstance(status.devices[0].ipaddress,
|
|
522
|
+
self.assertIsInstance(status.devices[0].ipaddress, IPv4Address)
|
|
507
523
|
self.assertEqual(status.devices[0].hostname, 'SERVER')
|
|
508
524
|
self.assertEqual(status.devices[0].packets_sent, None)
|
|
509
525
|
self.assertEqual(status.devices[0].packets_received, None)
|
|
510
526
|
self.assertIsInstance(status.devices[1], Device)
|
|
511
527
|
self.assertEqual(status.devices[1].type, Connection.WIRED)
|
|
512
528
|
self.assertEqual(status.devices[1].macaddr, 'AC-04-D6-25-2A-96')
|
|
513
|
-
self.assertIsInstance(status.devices[1].macaddress,
|
|
529
|
+
self.assertIsInstance(status.devices[1].macaddress, EUI48)
|
|
514
530
|
self.assertEqual(status.devices[1].ipaddr, '192.168.1.254')
|
|
515
|
-
self.assertIsInstance(status.devices[1].ipaddress,
|
|
531
|
+
self.assertIsInstance(status.devices[1].ipaddress, IPv4Address)
|
|
516
532
|
self.assertEqual(status.devices[1].hostname, 'UNKNOWN')
|
|
517
533
|
self.assertEqual(status.devices[1].packets_sent, None)
|
|
518
534
|
self.assertEqual(status.devices[1].packets_received, None)
|
|
519
535
|
self.assertIsInstance(status.devices[2], Device)
|
|
520
536
|
self.assertEqual(status.devices[2].type, Connection.HOST_2G)
|
|
521
537
|
self.assertEqual(status.devices[2].macaddr, '06-82-9D-2B-8F-C6')
|
|
522
|
-
self.assertIsInstance(status.devices[2].macaddress,
|
|
538
|
+
self.assertIsInstance(status.devices[2].macaddress, EUI48)
|
|
523
539
|
self.assertEqual(status.devices[2].ipaddr, '192.168.1.186')
|
|
524
|
-
self.assertIsInstance(status.devices[2].ipaddress,
|
|
540
|
+
self.assertIsInstance(status.devices[2].ipaddress, IPv4Address)
|
|
525
541
|
self.assertEqual(status.devices[2].hostname, 'UNKNOWN')
|
|
526
542
|
self.assertEqual(status.devices[2].packets_sent, 450333)
|
|
527
543
|
self.assertEqual(status.devices[2].packets_received, 4867482)
|
|
@@ -530,36 +546,36 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
530
546
|
self.assertIsInstance(status.devices[3], Device)
|
|
531
547
|
self.assertEqual(status.devices[3].type, Connection.IOT_2G)
|
|
532
548
|
self.assertEqual(status.devices[3].macaddr, 'FB-90-B8-2A-8A-B1')
|
|
533
|
-
self.assertIsInstance(status.devices[3].macaddress,
|
|
549
|
+
self.assertIsInstance(status.devices[3].macaddress, EUI48)
|
|
534
550
|
self.assertEqual(status.devices[3].ipaddr, '192.168.1.187')
|
|
535
|
-
self.assertIsInstance(status.devices[3].ipaddress,
|
|
551
|
+
self.assertIsInstance(status.devices[3].ipaddress, IPv4Address)
|
|
536
552
|
self.assertEqual(status.devices[3].hostname, 'name2')
|
|
537
553
|
self.assertEqual(status.devices[3].packets_sent, None)
|
|
538
554
|
self.assertEqual(status.devices[3].packets_received, None)
|
|
539
555
|
self.assertIsInstance(status.devices[4], Device)
|
|
540
556
|
self.assertEqual(status.devices[4].type, Connection.IOT_5G)
|
|
541
557
|
self.assertEqual(status.devices[4].macaddr, '54-B3-A2-F7-BE-EA')
|
|
542
|
-
self.assertIsInstance(status.devices[4].macaddress,
|
|
558
|
+
self.assertIsInstance(status.devices[4].macaddress, EUI48)
|
|
543
559
|
self.assertEqual(status.devices[4].ipaddr, '192.168.1.188')
|
|
544
|
-
self.assertIsInstance(status.devices[4].ipaddress,
|
|
560
|
+
self.assertIsInstance(status.devices[4].ipaddress, IPv4Address)
|
|
545
561
|
self.assertEqual(status.devices[4].hostname, 'name3')
|
|
546
562
|
self.assertEqual(status.devices[4].packets_sent, None)
|
|
547
563
|
self.assertEqual(status.devices[4].packets_received, None)
|
|
548
564
|
self.assertIsInstance(status.devices[5], Device)
|
|
549
565
|
self.assertEqual(status.devices[5].type, Connection.IOT_6G)
|
|
550
566
|
self.assertEqual(status.devices[5].macaddr, '3C-AE-E1-83-94-9D')
|
|
551
|
-
self.assertIsInstance(status.devices[5].macaddress,
|
|
567
|
+
self.assertIsInstance(status.devices[5].macaddress, EUI48)
|
|
552
568
|
self.assertEqual(status.devices[5].ipaddr, '192.168.1.189')
|
|
553
|
-
self.assertIsInstance(status.devices[5].ipaddress,
|
|
569
|
+
self.assertIsInstance(status.devices[5].ipaddress, IPv4Address)
|
|
554
570
|
self.assertEqual(status.devices[5].hostname, 'name4')
|
|
555
571
|
self.assertEqual(status.devices[5].packets_sent, None)
|
|
556
572
|
self.assertEqual(status.devices[5].packets_received, None)
|
|
557
573
|
self.assertIsInstance(status.devices[6], Device)
|
|
558
574
|
self.assertEqual(status.devices[6].type, Connection.HOST_5G)
|
|
559
575
|
self.assertEqual(status.devices[6].macaddr, '1F-7A-BD-F7-20-0D')
|
|
560
|
-
self.assertIsInstance(status.devices[6].macaddress,
|
|
576
|
+
self.assertIsInstance(status.devices[6].macaddress, EUI48)
|
|
561
577
|
self.assertEqual(status.devices[6].ipaddr, '0.0.0.0')
|
|
562
|
-
self.assertIsInstance(status.devices[6].ipaddress,
|
|
578
|
+
self.assertIsInstance(status.devices[6].ipaddress, IPv4Address)
|
|
563
579
|
self.assertEqual(status.devices[6].hostname, '')
|
|
564
580
|
self.assertEqual(status.devices[6].packets_sent, 134815)
|
|
565
581
|
self.assertEqual(status.devices[6].packets_received, 2953078)
|
|
@@ -596,11 +612,11 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
596
612
|
def request(self, path: str, data: str,
|
|
597
613
|
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
598
614
|
if path == 'admin/status?form=all&operation=read':
|
|
599
|
-
return
|
|
615
|
+
return loads(response_status)['data']
|
|
600
616
|
elif path == 'admin/status?form=perf&operation=read':
|
|
601
|
-
return
|
|
617
|
+
return loads(perf_stats)['data']
|
|
602
618
|
elif path == 'admin/wireless?form=statistics':
|
|
603
|
-
return
|
|
619
|
+
return loads(response_stats)['data']
|
|
604
620
|
raise ClientException()
|
|
605
621
|
|
|
606
622
|
client = TPLinkRouterTest('', '')
|
|
@@ -609,7 +625,7 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
609
625
|
self.assertIsInstance(status, Status)
|
|
610
626
|
self.assertEqual(status.wan_macaddr, None)
|
|
611
627
|
self.assertEqual(status.lan_macaddr, '06-E6-97-9E-23-F5')
|
|
612
|
-
self.assertIsInstance(status.lan_macaddress,
|
|
628
|
+
self.assertIsInstance(status.lan_macaddress, EUI48)
|
|
613
629
|
self.assertEqual(status.wan_ipv4_addr, None)
|
|
614
630
|
self.assertEqual(status.lan_ipv4_addr, None)
|
|
615
631
|
self.assertEqual(status.wan_ipv4_gateway, None)
|
|
@@ -679,4 +695,4 @@ class TestTPLinkClient(unittest.TestCase):
|
|
|
679
695
|
|
|
680
696
|
|
|
681
697
|
if __name__ == '__main__':
|
|
682
|
-
|
|
698
|
+
main()
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
from unittest import main, TestCase
|
|
2
|
+
from json import loads
|
|
3
3
|
from tplinkrouterc6u import (
|
|
4
4
|
TplinkC1200Router,
|
|
5
5
|
Connection,
|
|
6
6
|
ClientException
|
|
7
7
|
)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
class TestTPLinkC1200Client(TestCase):
|
|
10
11
|
|
|
11
12
|
def test_set_led_on(self) -> None:
|
|
12
13
|
|
|
@@ -30,18 +31,18 @@ class TestTPLinkC1200Client(unittest.TestCase):
|
|
|
30
31
|
def request(self, path: str, data: str,
|
|
31
32
|
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
32
33
|
if path == 'admin/ledgeneral?form=setting&operation=read':
|
|
33
|
-
return
|
|
34
|
+
return loads(response_led_general_read)
|
|
34
35
|
if path == 'admin/ledgeneral?form=setting&operation=write':
|
|
35
36
|
self.captured_path = path
|
|
36
|
-
return
|
|
37
|
+
return loads(response_led_general_write)
|
|
37
38
|
raise ClientException()
|
|
38
39
|
|
|
39
40
|
client = TPLinkRouterTest('', '')
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
client.set_led(True)
|
|
42
43
|
|
|
43
44
|
expected_path = "admin/ledgeneral?form=setting&operation=write"
|
|
44
|
-
|
|
45
|
+
|
|
45
46
|
self.assertEqual(client.captured_path, expected_path)
|
|
46
47
|
|
|
47
48
|
def test_set_led_off(self) -> None:
|
|
@@ -66,10 +67,10 @@ class TestTPLinkC1200Client(unittest.TestCase):
|
|
|
66
67
|
def request(self, path: str, data: str,
|
|
67
68
|
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
68
69
|
if path == 'admin/ledgeneral?form=setting&operation=read':
|
|
69
|
-
return
|
|
70
|
+
return loads(response_led_general_read)
|
|
70
71
|
elif path == 'admin/ledgeneral?form=setting&operation=write':
|
|
71
72
|
self.captured_path = path
|
|
72
|
-
return
|
|
73
|
+
return loads(response_led_general_write)
|
|
73
74
|
raise ClientException()
|
|
74
75
|
|
|
75
76
|
client = TPLinkRouterTest('', '')
|
|
@@ -77,7 +78,7 @@ class TestTPLinkC1200Client(unittest.TestCase):
|
|
|
77
78
|
client.set_led(False)
|
|
78
79
|
|
|
79
80
|
expected_path = "admin/ledgeneral?form=setting&operation=write"
|
|
80
|
-
|
|
81
|
+
|
|
81
82
|
self.assertEqual(client.captured_path, expected_path)
|
|
82
83
|
|
|
83
84
|
def test_led_status(self) -> None:
|
|
@@ -89,12 +90,12 @@ class TestTPLinkC1200Client(unittest.TestCase):
|
|
|
89
90
|
"ledpm_support": "yes"
|
|
90
91
|
}
|
|
91
92
|
'''
|
|
92
|
-
|
|
93
|
+
|
|
93
94
|
class TPLinkRouterTest(TplinkC1200Router):
|
|
94
95
|
def request(self, path: str, data: str,
|
|
95
96
|
ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
|
|
96
97
|
if path == 'admin/ledgeneral?form=setting&operation=read':
|
|
97
|
-
return
|
|
98
|
+
return loads(response_led_general_read)
|
|
98
99
|
raise ClientException()
|
|
99
100
|
|
|
100
101
|
client = TPLinkRouterTest('', '')
|
|
@@ -102,7 +103,6 @@ class TestTPLinkC1200Client(unittest.TestCase):
|
|
|
102
103
|
led_status = client.get_led()
|
|
103
104
|
self.assertTrue(led_status)
|
|
104
105
|
|
|
105
|
-
|
|
106
106
|
def test_set_wifi(self) -> None:
|
|
107
107
|
|
|
108
108
|
class TPLinkRouterTest(TplinkC1200Router):
|
|
@@ -128,14 +128,15 @@ class TestTPLinkC1200Client(unittest.TestCase):
|
|
|
128
128
|
txpower="20",
|
|
129
129
|
disabled_all="no"
|
|
130
130
|
)
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
expected_data = ("operation=write&enable=on&ssid=TestSSID&hidden=no&encryption=WPA3-PSK&"
|
|
133
133
|
"psk_version=2&psk_cipher=AES&psk_key=testkey123&hwmode=11ac&"
|
|
134
134
|
"htmode=VHT20&channel=36&txpower=20&disabled_all=no")
|
|
135
135
|
expected_path = f"admin/wireless?form=wireless_5g&{expected_data}"
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
self.assertEqual(client.captured_path, expected_path)
|
|
138
138
|
self.assertEqual(client.captured_data, expected_data)
|
|
139
139
|
|
|
140
|
+
|
|
140
141
|
if __name__ == '__main__':
|
|
141
|
-
|
|
142
|
+
main()
|