tplinkrouterc6u 5.10.0__py3-none-any.whl → 5.10.1__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_c6u.py CHANGED
@@ -769,6 +769,69 @@ class TestTPLinkClient(TestCase):
769
769
  self.assertEqual(result.wan_ipv4_gateway, '0.0.0.0')
770
770
  self.assertEqual(result.lan_macaddr, '06-E6-97-9E-23-F5')
771
771
 
772
+ def test_get_status_wifi_disabled(self) -> None:
773
+ """Test that get_status gracefully handles when WiFi is disabled and wireless statistics fail."""
774
+ response_status = '''
775
+ {
776
+ "success": true,
777
+ "data": {
778
+ "lan_macaddr": "06:e6:97:9e:23:f5",
779
+ "wan_macaddr": "06:e6:97:9e:23:f6",
780
+ "wan_ipv4_ipaddr": "192.168.1.1",
781
+ "wan_ipv4_gateway": "192.168.1.254",
782
+ "lan_ipv4_ipaddr": "192.168.0.1",
783
+ "mem_usage": 0.43,
784
+ "cpu_usage": 0.28,
785
+ "conn_type": "1",
786
+ "access_devices_wired": [
787
+ {
788
+ "wire_type": "wired",
789
+ "macaddr": "3d:24:25:24:30:79",
790
+ "ipaddr": "192.168.1.228",
791
+ "hostname": "SERVER"
792
+ }
793
+ ],
794
+ "access_devices_wireless_host": [],
795
+ "access_devices_wireless_guest": [],
796
+ "wireless_2g_enable": "off",
797
+ "wireless_5g_enable": "off",
798
+ "guest_2g_enable": "off",
799
+ "guest_5g_enable": "off"
800
+ }
801
+ }
802
+ '''
803
+
804
+ class TPLinkRouterTest(TplinkRouter):
805
+ def request(self, path: str, data: str,
806
+ ignore_response: bool = False, ignore_errors: bool = False) -> dict | None:
807
+ if path == 'admin/status?form=all&operation=read':
808
+ return loads(response_status)['data']
809
+ elif path == 'admin/wireless?form=statistics':
810
+ # Simulate the error that occurs when WiFi is disabled
811
+ from tplinkrouterc6u.common.exception import ClientError
812
+ raise ClientError('TplinkRouter - An unknown response - Expecting value: line 1 column 1 (char 0)')
813
+ raise ClientException()
814
+
815
+ client = TPLinkRouterTest('', '')
816
+ result = client.get_status()
817
+
818
+ # Should complete successfully without crashing
819
+ self.assertIsInstance(result, Status)
820
+ self.assertEqual(result.wan_macaddr, '06-E6-97-9E-23-F6')
821
+ self.assertEqual(result.lan_macaddr, '06-E6-97-9E-23-F5')
822
+ self.assertEqual(result.wan_ipv4_addr, '192.168.1.1')
823
+ self.assertEqual(result.wan_ipv4_gateway, '192.168.1.254')
824
+ self.assertEqual(result.lan_ipv4_addr, '192.168.0.1')
825
+ self.assertEqual(result.wired_total, 1)
826
+ self.assertEqual(result.wifi_clients_total, 0)
827
+ self.assertEqual(result.guest_clients_total, 0)
828
+ self.assertEqual(result.clients_total, 1)
829
+ self.assertEqual(result.wifi_2g_enable, False)
830
+ self.assertEqual(result.wifi_5g_enable, False)
831
+ # Devices list should only contain wired devices
832
+ self.assertEqual(len(result.devices), 1)
833
+ self.assertEqual(result.devices[0].type, Connection.WIRED)
834
+
772
835
  def test_vpn_status(self) -> None:
773
836
  response_openvpn_read = """
774
837
  {
@@ -360,14 +360,19 @@ class TplinkBaseRouter(AbstractRouter, TplinkRequest):
360
360
  devices[item['mac']].up_speed = item.get('uploadSpeed')
361
361
  devices[item['mac']].signal = int(item.get('signal')) if item.get('signal') else None
362
362
 
363
- for item in self.request('admin/wireless?form=statistics', 'operation=load'):
364
- if item['mac'] not in devices:
365
- status.wifi_clients_total += 1
366
- type = self._map_wire_type(item.get('type'))
367
- devices[item['mac']] = Device(type, EUI48(item['mac']), IPv4Address('0.0.0.0'),
368
- '')
369
- devices[item['mac']].packets_sent = item.get('txpkts')
370
- devices[item['mac']].packets_received = item.get('rxpkts')
363
+ try:
364
+ wireless_stats = self.request('admin/wireless?form=statistics', 'operation=load')
365
+ for item in wireless_stats:
366
+ if item['mac'] not in devices:
367
+ status.wifi_clients_total += 1
368
+ type = self._map_wire_type(item.get('type'))
369
+ devices[item['mac']] = Device(type, EUI48(item['mac']), IPv4Address('0.0.0.0'),
370
+ '')
371
+ devices[item['mac']].packets_sent = item.get('txpkts')
372
+ devices[item['mac']].packets_received = item.get('rxpkts')
373
+ except Exception:
374
+ # WiFi might be disabled on the router, skip wireless statistics
375
+ pass
371
376
 
372
377
  status.devices = list(devices.values())
373
378
  status.clients_total = status.wired_total + status.wifi_clients_total + status.guest_clients_total
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tplinkrouterc6u
3
- Version: 5.10.0
3
+ Version: 5.10.1
4
4
  Summary: TP-Link Router API (supports also Mercusys Router)
5
5
  Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
6
6
  Author: Alex Erohin
@@ -1,6 +1,6 @@
1
1
  test/__init__.py,sha256=McQmUjeN3AwmwdS6QNfwGXXE77OKoPK852I2BM9XsrU,210
2
2
  test/test_client_c1200.py,sha256=Sl-85JGqINNg-ckBZCIVqY0CC-V1UOc-yiIUljtePRM,7582
3
- test/test_client_c6u.py,sha256=VpxF5etPtGYuXX9TfUl78tOj0pjozvPkrVx6FKbZDjQ,37585
3
+ test/test_client_c6u.py,sha256=j9IpkZaWAedqkSktIGhjK8YZMhCkQhHnhqAmAWzEAYc,40399
4
4
  test/test_client_c80.py,sha256=RY_1SgRVcQQdN9h0_IXA0YW4_0flEB_uel05QvDDfws,42359
5
5
  test/test_client_deco.py,sha256=YPLKRD8GoyDYHfRgdXvCk8iVNw8zdMJW-AHVnNbpdTM,31719
6
6
  test/test_client_ex.py,sha256=Kg6svEKtyGAfyF9yrLh2qZa2tK1mlEBJJwXRsq1MAjo,26591
@@ -13,7 +13,7 @@ tplinkrouterc6u/provider.py,sha256=bzH0WW2peC66f8NqfiI3t_niX6MFO8SAdKP9WZL-IV4,2
13
13
  tplinkrouterc6u/client/__init__.py,sha256=KBy3fmtA9wgyFrb0Urh2x4CkKtWVnESdp-vxmuOvq0k,27
14
14
  tplinkrouterc6u/client/c1200.py,sha256=4XEYidEGmVIJk0YQLvmTnd0Gqa7glH2gUWvjreHpWrk,3178
15
15
  tplinkrouterc6u/client/c5400x.py,sha256=9E0omBSbWY_ljrs5MTCMu5brmrLtzsDB5O62Db8lP8Q,4329
16
- tplinkrouterc6u/client/c6u.py,sha256=3Jon6_WZkaCyrbTAp9TckB-SIXLP_JyB5gtRI65IuVI,19485
16
+ tplinkrouterc6u/client/c6u.py,sha256=n4OMAxg0NXChYaVpWCvx3ZFUxVfynTMy-pyd1CTj9s4,19694
17
17
  tplinkrouterc6u/client/c80.py,sha256=ArVhza_fnXcEO-_fsQOd1l2QvmSfsswtohKxrZxEnoU,18568
18
18
  tplinkrouterc6u/client/deco.py,sha256=cpKRggKD2RvSmMZuD6tzsZmehAUCU9oLiTTHcZBW81Y,8898
19
19
  tplinkrouterc6u/client/ex.py,sha256=gXWsVKAMo4CsX_Qeihb2iCARcsA3E9m2vgIWiJB3sjs,13197
@@ -27,8 +27,8 @@ tplinkrouterc6u/common/encryption.py,sha256=4HelTxzN6esMfDZRBt3m8bwB9Nj_biKijnCn
27
27
  tplinkrouterc6u/common/exception.py,sha256=_0G8ZvW5__CsGifHrsZeULdl8c6EUD071sDCQsQgrHY,140
28
28
  tplinkrouterc6u/common/helper.py,sha256=23b04fk9HuVinrZXMCS5R1rmF8uZ7eM-Cdnp7Br9NR0,572
29
29
  tplinkrouterc6u/common/package_enum.py,sha256=4ykL_2Pw0nDEIH_qR9UJlFF6stTgSfhPz32r8KT-sh8,1624
30
- tplinkrouterc6u-5.10.0.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
31
- tplinkrouterc6u-5.10.0.dist-info/METADATA,sha256=33mzp1gSyNl5dsHOZQfSCs-ZC530hhC70nn-kXxxqBs,16373
32
- tplinkrouterc6u-5.10.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- tplinkrouterc6u-5.10.0.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
34
- tplinkrouterc6u-5.10.0.dist-info/RECORD,,
30
+ tplinkrouterc6u-5.10.1.dist-info/licenses/LICENSE,sha256=YF6QR6Vjxcg5b_sYIyqkME7FZYau5TfEUGTG-0JeRK0,35129
31
+ tplinkrouterc6u-5.10.1.dist-info/METADATA,sha256=oiaqPd4N9hGpncj_Zm7WWQNi7w3orZbIRuTOqrEYhBE,16373
32
+ tplinkrouterc6u-5.10.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ tplinkrouterc6u-5.10.1.dist-info/top_level.txt,sha256=1iSCCIueqgEkrTxtQ-jiHe99jAB10zqrVdBcwvNfe_M,21
34
+ tplinkrouterc6u-5.10.1.dist-info/RECORD,,