tplinkrouterc6u 5.12.3__py3-none-any.whl → 5.13.0__py3-none-any.whl

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.
test/test_client_r.py ADDED
@@ -0,0 +1,633 @@
1
+ import json
2
+ from ipaddress import IPv4Address
3
+ from unittest import TestCase, main
4
+
5
+ from macaddress import EUI48
6
+
7
+ from tplinkrouterc6u.client.r import TPLinkRClient
8
+ from tplinkrouterc6u.common.dataclass import (Device, Firmware, IPv4DHCPLease,
9
+ IPv4Reservation, Status)
10
+ from tplinkrouterc6u.common.helper import get_ip, get_mac
11
+ from tplinkrouterc6u.common.package_enum import Connection
12
+
13
+
14
+ class TestTPLinkRClient(TestCase):
15
+
16
+ def test_supports_false(self) -> None:
17
+ class SessionTest:
18
+ def get(self, host, timeout, verify):
19
+ class ResponseTest:
20
+ def __init__(self):
21
+ self.text = 'text'
22
+
23
+ return ResponseTest()
24
+
25
+ client = TPLinkRClient('', '')
26
+ client._session = SessionTest()
27
+
28
+ self.assertEqual(client.supports(), False)
29
+
30
+ def test_supports_true(self) -> None:
31
+ response = '''
32
+ <html xmlns="http://www.w3.org/1999/xhtml">
33
+ <head>
34
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
35
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
36
+ <meta data-interface-type="SLP" />
37
+ <!-- ... -->
38
+ <title>Opening...</title>
39
+ </head>
40
+ <body class="login-body">
41
+ <noscript>
42
+ <meta http-equiv="refresh" content="0; url=error.htm"/>
43
+ </noscript>
44
+ <script type="text/javascript">
45
+ //<![CDATA[
46
+ $(document).ready(function(e){
47
+ var radio = 0;
48
+ var is_sar = 0;
49
+ var locale = "zh_CN";
50
+ var force = false;
51
+ var model = "TL-R470GP-AC";
52
+ // 是否是出厂设置
53
+ // Default: 恢复出厂设置后第一次登录
54
+ // Modify: 不是恢复出厂设置后第一次登录
55
+ var config_status = "Modify";
56
+ var interface_model = 5;
57
+ var single_wan = 1;
58
+ var interface_count = 5;
59
+ var router_list = [{"mac":"80-EA-07-CC-28-B4","ip":"192.168.60.1","dev_name":"TL-R470GP-AC 4.0"}];
60
+ // ...
61
+ });
62
+ //]]>
63
+ </script>
64
+ </body>
65
+ </html>
66
+ '''
67
+
68
+ class SessionTest:
69
+ def get(self, host, timeout, verify):
70
+ class ResponseTest:
71
+ def __init__(self):
72
+ self.text = response
73
+
74
+ return ResponseTest()
75
+
76
+ client = TPLinkRClient('', '')
77
+ client._session = SessionTest()
78
+
79
+ self.assertEqual(client.supports(), True)
80
+
81
+ def test_get_firmware(self) -> None:
82
+ mock_data = json.loads('''
83
+ {
84
+ "device_info": {
85
+ "info": {
86
+ ".name": "info",
87
+ "radio_count": "0",
88
+ "zone_code": "0x0",
89
+ "manufacturer_name": "TP-LINK",
90
+ "sw_version": "2.0.0%20Build%20211008%20Rel.48276n",
91
+ "manufacturer_url": "www.tp-link.com.cn",
92
+ "language": "CN",
93
+ "domain_name": "tplogin.cn",
94
+ ".type": "info",
95
+ "sys_software_revision": "0x500a0200",
96
+ "product_id": "62042BE0",
97
+ "fw_description": "R470GPACV4",
98
+ "hw_version": "4.0",
99
+ ".anonymous": false,
100
+ "device_name": "TL-R470GP-AC%204.0",
101
+ "vendor_id": "0x00000001",
102
+ "device_model": "TL-R470GP-AC",
103
+ "enable_dns": "1",
104
+ "device_info": "TL-R470GP-AC%204.0",
105
+ "sys_software_revision_minor": "0x0000",
106
+ "device_type": "SMBROUTER"
107
+ }
108
+ },
109
+ "error_code": 0
110
+ }
111
+ ''')
112
+ check_payload = {}
113
+
114
+ class TPLinkRClientTest(TPLinkRClient):
115
+ def _request(self, payload: dict) -> dict:
116
+ nonlocal check_payload
117
+ check_payload = payload
118
+ return mock_data
119
+
120
+ client = TPLinkRClientTest('', '')
121
+ firmware = client.get_firmware()
122
+
123
+ self.assertEqual(check_payload['method'], 'get')
124
+ self.assertIn('device_info', check_payload)
125
+ self.assertIn('name', check_payload['device_info'])
126
+ self.assertEqual(check_payload['device_info']['name'], 'info')
127
+
128
+ self.assertIsInstance(firmware, Firmware)
129
+ self.assertEqual(firmware.firmware_version, '2.0.0 Build 211008 Rel.48276n')
130
+ self.assertEqual(firmware.hardware_version, '4.0')
131
+ self.assertEqual(firmware.model, 'TL-R470GP-AC')
132
+
133
+ def test_get_status(self) -> None:
134
+ mock_data = json.loads('''
135
+ {
136
+ "apmng_wserv": {
137
+ "wlan_serv": [
138
+ {
139
+ "wlan_serv_2": {
140
+ "ssidbrd": "1",
141
+ "encryption": "1",
142
+ "radius_ip": "0.0.0.0",
143
+ "isolate": "0",
144
+ "is_sys": "1",
145
+ "key": "xxxxxxxx",
146
+ "bw_ctrl_mode": "1",
147
+ "network_type": "1",
148
+ "default_bind_freq": "127",
149
+ "serv_id": "2",
150
+ "down_limit": "0",
151
+ "radius_port": "0",
152
+ "up_limit": "0",
153
+ "ssid": "xxx-IoT",
154
+ "priv_key": "3",
155
+ "cipher": "2",
156
+ "bw_ctrl_enable": "0",
157
+ "key_update_intv": "86400",
158
+ "auto_bind": "on",
159
+ "enable": "on",
160
+ "default_bind_vlan": "0",
161
+ "desc": "",
162
+ "radius_acct_port": "0",
163
+ "radius_pwd": "",
164
+ "ssid_code_type": "1",
165
+ "ssid_id": "",
166
+ "auth": "2"
167
+ }
168
+ },
169
+ {
170
+ "wlan_serv_3": {
171
+ "ssidbrd": "1",
172
+ "encryption": "0",
173
+ "radius_ip": "0.0.0.0",
174
+ "isolate": "0",
175
+ "is_sys": "1",
176
+ "key": "0",
177
+ "bw_ctrl_mode": "1",
178
+ "network_type": "2",
179
+ "default_bind_freq": "127",
180
+ "serv_id": "3",
181
+ "down_limit": "0",
182
+ "radius_port": "0",
183
+ "up_limit": "0",
184
+ "ssid": "xxx-Guest",
185
+ "priv_key": "4",
186
+ "cipher": "0",
187
+ "bw_ctrl_enable": "0",
188
+ "key_update_intv": "86400",
189
+ "auto_bind": "on",
190
+ "enable": "off",
191
+ "default_bind_vlan": "4084",
192
+ "desc": "",
193
+ "radius_acct_port": "0",
194
+ "radius_pwd": "",
195
+ "ssid_code_type": "1",
196
+ "ssid_id": "",
197
+ "auth": "3"
198
+ }
199
+ },
200
+ {
201
+ "wlan_serv_4": {
202
+ "ssidbrd": "1",
203
+ "encryption": "1",
204
+ "radius_ip": "0.0.0.0",
205
+ "isolate": "0",
206
+ "is_sys": "1",
207
+ "key": "xxxxxxxx",
208
+ "bw_ctrl_mode": "1",
209
+ "network_type": "1",
210
+ "default_bind_freq": "32512",
211
+ "serv_id": "4",
212
+ "down_limit": "0",
213
+ "radius_port": "0",
214
+ "up_limit": "0",
215
+ "ssid": "xxx",
216
+ "priv_key": "5",
217
+ "cipher": "2",
218
+ "bw_ctrl_enable": "0",
219
+ "key_update_intv": "86400",
220
+ "auto_bind": "on",
221
+ "enable": "on",
222
+ "default_bind_vlan": "0",
223
+ "desc": "",
224
+ "radius_acct_port": "0",
225
+ "radius_pwd": "",
226
+ "ssid_code_type": "1",
227
+ "ssid_id": "",
228
+ "auth": "2"
229
+ }
230
+ }
231
+ ],
232
+ "count": {
233
+ "wlan_serv": 3
234
+ }
235
+ },
236
+ "host_management": {
237
+ "host_info": [
238
+ {
239
+ "host_info_1": {
240
+ "up_speed": "0",
241
+ "connect_date": "2026%2f01%2f13",
242
+ "encode": "1",
243
+ "rssi": "-77",
244
+ "host_save": "off",
245
+ "ip": "192.168.60.112",
246
+ "is_cur_host": false,
247
+ "hostname": "iPhone",
248
+ "connect_time": "15%3a57%3a41",
249
+ "interface": "br-lan",
250
+ "up_limit": "0",
251
+ "type": "wireless",
252
+ "ssid": "xxx",
253
+ "freq_name": "5GHz",
254
+ "state": "online",
255
+ "freq_unit": "2",
256
+ "down_speed": "0",
257
+ "down_limit": "0",
258
+ "vlan_id": "0",
259
+ "mac": "46-22-C0-A6-AC-35",
260
+ "ap_name": "xxx-ap"
261
+ }
262
+ },
263
+ {
264
+ "host_info_2": {
265
+ "up_speed": "0",
266
+ "connect_date": "2026%2f01%2f09",
267
+ "encode": "1",
268
+ "rssi": "-68",
269
+ "host_save": "off",
270
+ "ip": "192.168.60.11",
271
+ "is_cur_host": false,
272
+ "hostname": "chuangmi_camera_ipc013",
273
+ "connect_time": "04%3a01%3a15",
274
+ "interface": "br-lan",
275
+ "up_limit": "0",
276
+ "type": "wireless",
277
+ "ssid": "xxx-IoT",
278
+ "freq_name": "2.4GHz",
279
+ "state": "online",
280
+ "freq_unit": "1",
281
+ "down_speed": "0",
282
+ "down_limit": "0",
283
+ "vlan_id": "0",
284
+ "mac": "44-23-7C-8F-C2-42",
285
+ "ap_name": "xxx-ap"
286
+ }
287
+ },
288
+ {
289
+ "host_info_3": {
290
+ "up_speed": "9",
291
+ "connect_date": "2026%2f01%2f13",
292
+ "encode": "1",
293
+ "rssi": "-54",
294
+ "host_save": "off",
295
+ "ip": "192.168.60.102",
296
+ "is_cur_host": true,
297
+ "hostname": "Mac",
298
+ "connect_time": "18%3a30%3a14",
299
+ "interface": "br-lan",
300
+ "up_limit": "0",
301
+ "type": "wireless",
302
+ "ssid": "xxx",
303
+ "freq_name": "5GHz",
304
+ "state": "online",
305
+ "freq_unit": "2",
306
+ "down_speed": "3",
307
+ "down_limit": "0",
308
+ "vlan_id": "0",
309
+ "mac": "C6-FD-4C-A8-D5-BA",
310
+ "ap_name": "yyy-ap"
311
+ }
312
+ },
313
+ {
314
+ "host_info_4": {
315
+ "mac": "02-42-AC-10-00-01",
316
+ "type": "wired",
317
+ "down_speed": "16",
318
+ "host_save": "off",
319
+ "ip": "192.168.60.2",
320
+ "state": "online",
321
+ "is_cur_host": false,
322
+ "up_speed": "2",
323
+ "hostname": "anonymous",
324
+ "down_limit": "0",
325
+ "up_limit": "0",
326
+ "interface": "br-lan"
327
+ }
328
+ },
329
+ {
330
+ "host_info_5": {
331
+ ".name": "2EDE61E7EA70",
332
+ "up_speed": "0",
333
+ "host_save": "on",
334
+ "ip": "192.168.60.212",
335
+ "time_obj": "any",
336
+ "is_cur_host": "false",
337
+ "limit": "0",
338
+ "hostname": "xxx",
339
+ "interface": "br-lan",
340
+ "up_limit": "0",
341
+ "type": "wireless",
342
+ "ssid": "xxx",
343
+ "down_speed": "0",
344
+ "state": "offline",
345
+ "mac": "2E-DE-61-E7-EA-70",
346
+ ".anonymous": false,
347
+ "down_limit": "0",
348
+ "time_mode": "any",
349
+ ".type": "host_info",
350
+ "dev_state": "on"
351
+ }
352
+ }
353
+ ],
354
+ "count": {
355
+ "host_info": 5
356
+ }
357
+ },
358
+ "network": {
359
+ "lan": {
360
+ "ifname": [
361
+ "eth0.1",
362
+ "eth0.4084"
363
+ ],
364
+ "ipaddr": "192.168.60.1",
365
+ "netmask": "255.255.255.0",
366
+ "type": "bridge",
367
+ "proto": "static",
368
+ "prefix_if": "WAN",
369
+ "ip6ifaceid": "eui64",
370
+ "fac_ipaddr": "192.168.1.1",
371
+ "prefix": "2408%3a8340%3a111%3a1111%3a%3a",
372
+ "ip6addr": "2408%3a8340%3a111%3a1111%3a1111%3a111%3a1111%3a1111",
373
+ "fac_netmask": "255.255.255.0",
374
+ "macaddr": "80-EA-07-CC-28-B4",
375
+ "ipv6_enable": "on",
376
+ "ip_mode": "manual"
377
+ },
378
+ "wan_status": {
379
+ "down_speed": 1077,
380
+ "up_speed": 60,
381
+ "pri_dns": "221.12.1.227",
382
+ "link_status": 1,
383
+ "netmask": "255.255.255.255",
384
+ "error_code": 0,
385
+ "phy_status": 1,
386
+ "proto": "pppoe",
387
+ "gateway": "172.21.192.1",
388
+ "up_time": 403611,
389
+ "snd_dns": "221.12.33.227",
390
+ "ipaddr": "172.21.199.238"
391
+ }
392
+ },
393
+ "error_code": 0
394
+ }
395
+ ''')
396
+ check_payload = {}
397
+
398
+ class TPLinkRClientTest(TPLinkRClient):
399
+ def _request(self, payload: dict) -> dict:
400
+ nonlocal check_payload
401
+ check_payload = payload
402
+ return mock_data
403
+
404
+ client = TPLinkRClientTest('', '')
405
+ status = client.get_status()
406
+
407
+ self.assertEqual(check_payload['method'], 'get')
408
+ self.assertEqual(check_payload['host_management']['table'], ['host_info'])
409
+ self.assertIn('network', check_payload)
410
+ self.assertIn('name', check_payload['network'])
411
+ self.assertEqual(check_payload['network']['name'], ['wan_status', 'lan'])
412
+ self.assertIn('apmng_wserv', check_payload)
413
+ self.assertEqual(check_payload['apmng_wserv']['table'], ['wlan_serv'])
414
+
415
+ self.assertIsInstance(status, Status)
416
+ self.assertEqual(status.lan_ipv4_addr, '192.168.60.1')
417
+ self.assertIsInstance(status.lan_ipv4_address, IPv4Address)
418
+ self.assertEqual(status.lan_macaddr, '80-EA-07-CC-28-B4')
419
+ self.assertIsInstance(status.lan_macaddress, EUI48)
420
+ self.assertEqual(status.wan_ipv4_addr, '172.21.199.238')
421
+ self.assertIsInstance(status.wan_ipv4_address, IPv4Address)
422
+ self.assertEqual(status.wan_ipv4_gateway, '172.21.192.1')
423
+ self.assertEqual(status.wan_ipv4_uptime, 403611)
424
+ self.assertTrue(status.wifi_2g_enable)
425
+ self.assertTrue(status.wifi_5g_enable)
426
+ self.assertEqual(len(status.devices), 5)
427
+ self.assertEqual(status.clients_total, 5)
428
+ self.assertEqual(status.wired_total, 1)
429
+ self.assertEqual(status.wifi_clients_total, 3)
430
+ self.assertIsInstance(status.devices[0], Device)
431
+ self.assertEqual(status.devices[0].type, Connection.HOST_5G)
432
+ self.assertEqual(status.devices[0].macaddr, '46-22-C0-A6-AC-35')
433
+ self.assertIsInstance(status.devices[0].macaddress, EUI48)
434
+ self.assertEqual(status.devices[0].ipaddr, '192.168.60.112')
435
+ self.assertIsInstance(status.devices[0].ipaddress, IPv4Address)
436
+ self.assertEqual(status.devices[0].hostname, 'iPhone')
437
+ self.assertIsInstance(status.devices[1], Device)
438
+ self.assertEqual(status.devices[1].type, Connection.HOST_2G)
439
+ self.assertEqual(status.devices[1].macaddr, '44-23-7C-8F-C2-42')
440
+ self.assertIsInstance(status.devices[1].macaddress, EUI48)
441
+ self.assertEqual(status.devices[1].ipaddr, '192.168.60.11')
442
+ self.assertIsInstance(status.devices[1].ipaddress, IPv4Address)
443
+ self.assertEqual(status.devices[1].hostname, 'chuangmi_camera_ipc013')
444
+ self.assertIsInstance(status.devices[4], Device)
445
+ self.assertEqual(status.devices[4].active, False)
446
+ self.assertEqual(status.devices[4].type, Connection.UNKNOWN)
447
+
448
+ def test_set_wifi_enable_guest_2g(self) -> None:
449
+ mock_data = json.loads('''{"error_code":0}''')
450
+ check_payload = {}
451
+
452
+ class TPLinkRClientTest(TPLinkRClient):
453
+ def _request(self, payload: dict) -> dict:
454
+ nonlocal check_payload
455
+ check_payload = payload
456
+ return mock_data
457
+
458
+ client = TPLinkRClientTest('', '')
459
+ client._serv_id_map = {
460
+ Connection.GUEST_2G: '2',
461
+ Connection.HOST_2G: '3',
462
+ Connection.HOST_5G: '4',
463
+ }
464
+ client.set_wifi(Connection.GUEST_2G, True)
465
+
466
+ self.assertEqual(check_payload['method'], 'set')
467
+ self.assertEqual(check_payload['apmng_wserv']['table'], 'wlan_serv')
468
+ self.assertEqual(check_payload['apmng_wserv']['filter'], [{'serv_id': '2'}])
469
+ self.assertEqual(check_payload['apmng_wserv']['para'], {'enable': 'on'})
470
+
471
+ def test_set_wifi_enable_host_2g(self) -> None:
472
+ mock_data = json.loads('''{"error_code":0}''')
473
+ check_payload = {}
474
+
475
+ class TPLinkRClientTest(TPLinkRClient):
476
+ def _request(self, payload: dict) -> dict:
477
+ nonlocal check_payload
478
+ check_payload = payload
479
+ return mock_data
480
+
481
+ client = TPLinkRClientTest('', '')
482
+ client._serv_id_map = {
483
+ Connection.GUEST_2G: '2',
484
+ Connection.HOST_2G: '3',
485
+ Connection.HOST_5G: '4',
486
+ }
487
+ client.set_wifi(Connection.HOST_2G, True)
488
+
489
+ self.assertEqual(check_payload['method'], 'set')
490
+ self.assertEqual(check_payload['apmng_wserv']['table'], 'wlan_serv')
491
+ self.assertEqual(check_payload['apmng_wserv']['filter'], [{'serv_id': '3'}])
492
+ self.assertEqual(check_payload['apmng_wserv']['para'], {'enable': 'on'})
493
+
494
+ def test_set_wifi_disable_host_5g(self) -> None:
495
+ mock_data = json.loads('''{"error_code":0}''')
496
+ check_payload = {}
497
+
498
+ class TPLinkRClientTest(TPLinkRClient):
499
+ def _request(self, payload: dict) -> dict:
500
+ nonlocal check_payload
501
+ check_payload = payload
502
+ return mock_data
503
+
504
+ client = TPLinkRClientTest('', '')
505
+ client._serv_id_map = {
506
+ Connection.GUEST_2G: '2',
507
+ Connection.HOST_2G: '3',
508
+ Connection.HOST_5G: '4',
509
+ }
510
+ client.set_wifi(Connection.HOST_5G, False)
511
+
512
+ self.assertEqual(check_payload['method'], 'set')
513
+ self.assertEqual(check_payload['apmng_wserv']['table'], 'wlan_serv')
514
+ self.assertEqual(check_payload['apmng_wserv']['filter'], [{'serv_id': '4'}])
515
+ self.assertEqual(check_payload['apmng_wserv']['para'], {'enable': 'off'})
516
+
517
+ def test_get_ipv4_reservations(self):
518
+ mock_data = json.loads('''
519
+ {
520
+ "dhcpd": {
521
+ "count": {
522
+ "dhcp_static": 1
523
+ },
524
+ "dhcp_static": [
525
+ {
526
+ "dhcp_static_1": {
527
+ "mac": "44-23-7C-8F-C2-42",
528
+ "note": "chuangmi_camera_ipc013",
529
+ "name": "44237C8FC242%2b192.168.60.11",
530
+ "enable": "on",
531
+ "ip": "192.168.60.11",
532
+ "dhcp_static_id": "1"
533
+ }
534
+ }
535
+ ]
536
+ },
537
+ "error_code": 0
538
+ }
539
+ ''')
540
+ check_payload = {}
541
+
542
+ class TPLinkRClientTest(TPLinkRClient):
543
+ def _request(self, payload: dict) -> dict:
544
+ nonlocal check_payload
545
+ check_payload = payload
546
+ return mock_data
547
+
548
+ client = TPLinkRClientTest('', '')
549
+ reservations = client.get_ipv4_reservations()
550
+
551
+ self.assertEqual(check_payload['method'], 'get')
552
+ self.assertIsInstance(check_payload['dhcpd'], dict)
553
+ self.assertEqual(check_payload['dhcpd']['table'], 'dhcp_static')
554
+
555
+ self.assertEqual(len(reservations), 1)
556
+ self.assertIsInstance(reservations[0], IPv4Reservation)
557
+ self.assertEqual(reservations[0].macaddr, '44-23-7C-8F-C2-42')
558
+ self.assertIsInstance(reservations[0].macaddress, EUI48)
559
+ self.assertEqual(reservations[0].macaddress, get_mac('44-23-7C-8F-C2-42'))
560
+ self.assertEqual(reservations[0].ipaddr, '192.168.60.11')
561
+ self.assertIsInstance(reservations[0].ipaddress, IPv4Address)
562
+ self.assertEqual(reservations[0].ipaddress, get_ip('192.168.60.11'))
563
+ self.assertEqual(reservations[0].hostname, 'chuangmi_camera_ipc013')
564
+
565
+ def test_get_ipv4_dhcp_leases(self):
566
+ mock_data = json.loads('''
567
+ {
568
+ "dhcpd": {
569
+ "dhcp_clients": [
570
+ {
571
+ "dhcp_client_1": {
572
+ "expires": "PERMANENT",
573
+ "ipaddr": "192.168.60.11",
574
+ "hostname": "chuangmi_camera_ipc013",
575
+ "macaddr": "44-23-7C-8F-C2-42",
576
+ "interface": "lan"
577
+ }
578
+ },
579
+ {
580
+ "dhcp_client_8": {
581
+ "expires": "114146",
582
+ "ipaddr": "192.168.60.106",
583
+ "hostname": "---",
584
+ "macaddr": "56-16-70-01-11-B9",
585
+ "interface": "lan"
586
+ }
587
+ }
588
+ ],
589
+ "count": {
590
+ "dhcp_clients": 2
591
+ }
592
+ },
593
+ "error_code": 0
594
+ }
595
+ ''')
596
+ check_payload = {}
597
+
598
+ class TPLinkRClientTest(TPLinkRClient):
599
+ def _request(self, payload: dict) -> dict:
600
+ nonlocal check_payload
601
+ check_payload = payload
602
+ return mock_data
603
+
604
+ client = TPLinkRClientTest('', '')
605
+ dhcp_leases = client.get_ipv4_dhcp_leases()
606
+
607
+ self.assertEqual(check_payload['method'], 'get')
608
+ self.assertIsInstance(check_payload['dhcpd'], dict)
609
+ self.assertEqual(check_payload['dhcpd']['table'], 'dhcp_clients')
610
+
611
+ self.assertEqual(len(dhcp_leases), 2)
612
+ self.assertIsInstance(dhcp_leases[0], IPv4DHCPLease)
613
+ self.assertEqual(dhcp_leases[0].macaddr, '44-23-7C-8F-C2-42')
614
+ self.assertIsInstance(dhcp_leases[0].macaddress, EUI48)
615
+ self.assertEqual(dhcp_leases[0].macaddress, get_mac('44-23-7C-8F-C2-42'))
616
+ self.assertEqual(dhcp_leases[0].ipaddr, '192.168.60.11')
617
+ self.assertIsInstance(dhcp_leases[0].ipaddress, IPv4Address)
618
+ self.assertEqual(dhcp_leases[0].ipaddress, get_ip('192.168.60.11'))
619
+ self.assertEqual(dhcp_leases[0].hostname, 'chuangmi_camera_ipc013')
620
+ self.assertEqual(dhcp_leases[0].lease_time, 'Permanent')
621
+ self.assertIsInstance(dhcp_leases[1], IPv4DHCPLease)
622
+ self.assertEqual(dhcp_leases[1].macaddr, '56-16-70-01-11-B9')
623
+ self.assertIsInstance(dhcp_leases[1].macaddress, EUI48)
624
+ self.assertEqual(dhcp_leases[1].macaddress, get_mac('56-16-70-01-11-B9'))
625
+ self.assertEqual(dhcp_leases[1].ipaddr, '192.168.60.106')
626
+ self.assertIsInstance(dhcp_leases[1].ipaddress, IPv4Address)
627
+ self.assertEqual(dhcp_leases[1].ipaddress, get_ip('192.168.60.106'))
628
+ self.assertEqual(dhcp_leases[1].hostname, '---')
629
+ self.assertEqual(dhcp_leases[1].lease_time, '1 day, 7:42:26')
630
+
631
+
632
+ if __name__ == '__main__':
633
+ main()
test/test_client_xdr.py CHANGED
@@ -311,9 +311,14 @@ maximum-scale=2.0, user-scalable=yes" />
311
311
  self.assertIsInstance(status.lan_macaddress, EUI48)
312
312
  self.assertEqual(status.wan_ipv4_addr, '0.0.0.0')
313
313
  self.assertIsInstance(status.wan_ipv4_address, IPv4Address)
314
+ self.assertEqual(status.wan_ipv4_gateway, '0.0.0.0')
315
+ self.assertEqual(status.wan_ipv4_uptime, 0)
314
316
  self.assertTrue(status.wifi_2g_enable)
315
317
  self.assertTrue(status.wifi_5g_enable)
316
318
  self.assertEqual(len(status.devices), 2)
319
+ self.assertEqual(status.clients_total, 2)
320
+ self.assertEqual(status.wired_total, 1)
321
+ self.assertEqual(status.wifi_clients_total, 1)
317
322
  self.assertIsInstance(status.devices[0], Device)
318
323
  self.assertEqual(status.devices[0].type, Connection.WIRED)
319
324
  self.assertEqual(status.devices[0].macaddr, 'B8-27-EB-0E-87-EB')
@@ -1,4 +1,4 @@
1
- from tplinkrouterc6u.client.c6u import TplinkRouter
1
+ from tplinkrouterc6u.client.c6u import TplinkRouter, TplinkRouterV1_11
2
2
  from tplinkrouterc6u.client.deco import TPLinkDecoClient
3
3
  from tplinkrouterc6u.client_abstract import AbstractRouter
4
4
  from tplinkrouterc6u.client.mr import TPLinkMRClient, TPLinkMRClientGCM
@@ -11,6 +11,7 @@ from tplinkrouterc6u.client.c5400x import TplinkC5400XRouter
11
11
  from tplinkrouterc6u.client.c1200 import TplinkC1200Router
12
12
  from tplinkrouterc6u.client.xdr import TPLinkXDRClient
13
13
  from tplinkrouterc6u.client.wdr import TplinkWDRRouter
14
+ from tplinkrouterc6u.client.r import TPLinkRClient
14
15
  from tplinkrouterc6u.client.re330 import TplinkRE330Router
15
16
  from tplinkrouterc6u.provider import TplinkRouterProvider
16
17
  from tplinkrouterc6u.common.package_enum import Connection, VPN