tplinkrouterc6u 5.1.0__py3-none-any.whl → 5.2.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.py → test_client_c6u.py} +2 -1
- test/test_client_mr.py +180 -0
- test/test_client_xdr.py +584 -0
- tplinkrouterc6u/__init__.py +5 -2
- tplinkrouterc6u/client/c5400x.py +1 -1
- tplinkrouterc6u/client/{api_cgi_bin.py → c6u.py} +1 -0
- tplinkrouterc6u/client/deco.py +1 -1
- tplinkrouterc6u/client/mr.py +68 -1
- tplinkrouterc6u/client/xdr.py +263 -0
- tplinkrouterc6u/common/dataclass.py +28 -0
- tplinkrouterc6u/common/package_enum.py +5 -0
- tplinkrouterc6u/provider.py +4 -2
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/METADATA +39 -4
- tplinkrouterc6u-5.2.1.dist-info/RECORD +30 -0
- tplinkrouterc6u-5.1.0.dist-info/RECORD +0 -28
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/LICENSE +0 -0
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/WHEEL +0 -0
- {tplinkrouterc6u-5.1.0.dist-info → tplinkrouterc6u-5.2.1.dist-info}/top_level.txt +0 -0
|
@@ -445,7 +445,7 @@ class TestTPLinkClient(TestCase):
|
|
|
445
445
|
{"mac": "54:b3:a2:f7:be:ea", "deviceTag":"iot_5G", "isGuest":false, "ip":"192.168.1.188",
|
|
446
446
|
"deviceName":"name3"},
|
|
447
447
|
{"mac": "3c:ae:e1:83:94:9d", "deviceTag":"iot_6G", "isGuest":false, "ip":"192.168.1.189",
|
|
448
|
-
"deviceName":"name4"}
|
|
448
|
+
"deviceName":"name4", "signal": -52}
|
|
449
449
|
],
|
|
450
450
|
"timeout": false,
|
|
451
451
|
"success": true
|
|
@@ -570,6 +570,7 @@ class TestTPLinkClient(TestCase):
|
|
|
570
570
|
self.assertEqual(status.devices[5].hostname, 'name4')
|
|
571
571
|
self.assertEqual(status.devices[5].packets_sent, None)
|
|
572
572
|
self.assertEqual(status.devices[5].packets_received, None)
|
|
573
|
+
self.assertEqual(status.devices[5].signal, -52)
|
|
573
574
|
self.assertIsInstance(status.devices[6], Device)
|
|
574
575
|
self.assertEqual(status.devices[6].type, Connection.HOST_5G)
|
|
575
576
|
self.assertEqual(status.devices[6].macaddr, '1F-7A-BD-F7-20-0D')
|
test/test_client_mr.py
CHANGED
|
@@ -13,6 +13,9 @@ from tplinkrouterc6u import (
|
|
|
13
13
|
IPv4Status,
|
|
14
14
|
ClientError,
|
|
15
15
|
SMS,
|
|
16
|
+
LTEStatus,
|
|
17
|
+
VPNStatus,
|
|
18
|
+
VPN,
|
|
16
19
|
)
|
|
17
20
|
|
|
18
21
|
|
|
@@ -864,6 +867,183 @@ unread=0
|
|
|
864
867
|
self.assertIn('http:///cgi_gdpr?_=', check_url)
|
|
865
868
|
self.assertEqual(check_data, '4\r\n[LTE_SMS_RECVMSGENTRY#2,0,0,0,0,0#0,0,0,0,0,0]0,0\r\n\r\n')
|
|
866
869
|
|
|
870
|
+
def test_get_lte_status(self) -> None:
|
|
871
|
+
response = '''[2,1,0,0,0,0]0
|
|
872
|
+
enable=1
|
|
873
|
+
connectStatus=4
|
|
874
|
+
networkType=3
|
|
875
|
+
roamingStatus=0
|
|
876
|
+
simStatus=3
|
|
877
|
+
[2,0,0,0,0,0]1
|
|
878
|
+
dataLimit=0
|
|
879
|
+
enablePaymentDay=0
|
|
880
|
+
curStatistics=0
|
|
881
|
+
totalStatistics=32779416.0000
|
|
882
|
+
enableDataLimit=0
|
|
883
|
+
limitation=0
|
|
884
|
+
curRxSpeed=85
|
|
885
|
+
curTxSpeed=1492
|
|
886
|
+
[2,1,0,0,0,0]2
|
|
887
|
+
smsUnreadCount=0
|
|
888
|
+
ussdStatus=0
|
|
889
|
+
smsSendResult=3
|
|
890
|
+
sigLevel=0
|
|
891
|
+
rfInfoRsrp=-105
|
|
892
|
+
rfInfoRsrq=-20
|
|
893
|
+
rfInfoSnr=-44
|
|
894
|
+
[2,1,0,0,0,0]3
|
|
895
|
+
spn=Full name
|
|
896
|
+
ispName=Name
|
|
897
|
+
[error]0
|
|
898
|
+
|
|
899
|
+
'''
|
|
900
|
+
|
|
901
|
+
class TPLinkMRClientTest(TPLinkMRClient):
|
|
902
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
903
|
+
return 200, response
|
|
904
|
+
|
|
905
|
+
client = TPLinkMRClientTest('', '')
|
|
906
|
+
status = client.get_lte_status()
|
|
907
|
+
|
|
908
|
+
self.assertIsInstance(status, LTEStatus)
|
|
909
|
+
self.assertEqual(status.enable, 1)
|
|
910
|
+
self.assertEqual(status.connect_status, 4)
|
|
911
|
+
self.assertEqual(status.network_type, 3)
|
|
912
|
+
self.assertEqual(status.sim_status, 3)
|
|
913
|
+
self.assertEqual(status.total_statistics, 32779416)
|
|
914
|
+
self.assertEqual(status.cur_rx_speed, 85)
|
|
915
|
+
self.assertEqual(status.cur_tx_speed, 1492)
|
|
916
|
+
self.assertEqual(status.sms_unread_count, 0)
|
|
917
|
+
self.assertEqual(status.sig_level, 0)
|
|
918
|
+
self.assertEqual(status.rsrp, -105)
|
|
919
|
+
self.assertEqual(status.rsrq, -20)
|
|
920
|
+
self.assertEqual(status.snr, -44)
|
|
921
|
+
self.assertEqual(status.isp_name, 'Name')
|
|
922
|
+
|
|
923
|
+
def test_get_lte_status_wrong(self) -> None:
|
|
924
|
+
response = '''[2,1,0,0,0,0]0
|
|
925
|
+
enable=1
|
|
926
|
+
connectStatus=1
|
|
927
|
+
networkType=2
|
|
928
|
+
roamingStatus=0
|
|
929
|
+
simStatus=1
|
|
930
|
+
[2,0,0,0,0,0]1
|
|
931
|
+
dataLimit=0
|
|
932
|
+
enablePaymentDay=0
|
|
933
|
+
curStatistics=0
|
|
934
|
+
totalStatistics=32779416.0000
|
|
935
|
+
enableDataLimit=0
|
|
936
|
+
limitation=0
|
|
937
|
+
curRxSpeed=0
|
|
938
|
+
curTxSpeed=0
|
|
939
|
+
[2,1,0,0,0,0]2
|
|
940
|
+
smsUnreadCount=0
|
|
941
|
+
ussdStatus=0
|
|
942
|
+
smsSendResult=3
|
|
943
|
+
sigLevel=2
|
|
944
|
+
rfInfoRsrp=0
|
|
945
|
+
rfInfoRsrq=0
|
|
946
|
+
rfInfoSnr=0
|
|
947
|
+
[2,1,0,0,0,0]3
|
|
948
|
+
spn=Full name
|
|
949
|
+
ispName=Name
|
|
950
|
+
[error]0
|
|
951
|
+
|
|
952
|
+
'''
|
|
953
|
+
|
|
954
|
+
class TPLinkMRClientTest(TPLinkMRClient):
|
|
955
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
956
|
+
return 200, response
|
|
957
|
+
|
|
958
|
+
client = TPLinkMRClientTest('', '')
|
|
959
|
+
status = client.get_lte_status()
|
|
960
|
+
|
|
961
|
+
self.assertIsInstance(status, LTEStatus)
|
|
962
|
+
|
|
963
|
+
def test_get_vpn_status(self) -> None:
|
|
964
|
+
response = '''[0,0,0,0,0,0]0
|
|
965
|
+
enable=1
|
|
966
|
+
[0,0,0,0,0,0]1
|
|
967
|
+
enable=0
|
|
968
|
+
[1,0,0,0,0,0]2
|
|
969
|
+
connAct=0
|
|
970
|
+
[2,0,0,0,0,0]2
|
|
971
|
+
connAct=0
|
|
972
|
+
[3,0,0,0,0,0]2
|
|
973
|
+
connAct=0
|
|
974
|
+
[4,0,0,0,0,0]2
|
|
975
|
+
connAct=0
|
|
976
|
+
[5,0,0,0,0,0]2
|
|
977
|
+
connAct=1
|
|
978
|
+
[6,0,0,0,0,0]2
|
|
979
|
+
connAct=1
|
|
980
|
+
[7,0,0,0,0,0]2
|
|
981
|
+
connAct=0
|
|
982
|
+
[8,0,0,0,0,0]2
|
|
983
|
+
connAct=0
|
|
984
|
+
[9,0,0,0,0,0]2
|
|
985
|
+
connAct=0
|
|
986
|
+
[10,0,0,0,0,0]2
|
|
987
|
+
connAct=0
|
|
988
|
+
[1,0,0,0,0,0]3
|
|
989
|
+
connAct=0
|
|
990
|
+
[2,0,0,0,0,0]3
|
|
991
|
+
connAct=0
|
|
992
|
+
[3,0,0,0,0,0]3
|
|
993
|
+
connAct=0
|
|
994
|
+
[4,0,0,0,0,0]3
|
|
995
|
+
connAct=0
|
|
996
|
+
[5,0,0,0,0,0]3
|
|
997
|
+
connAct=0
|
|
998
|
+
[6,0,0,0,0,0]3
|
|
999
|
+
connAct=0
|
|
1000
|
+
[7,0,0,0,0,0]3
|
|
1001
|
+
connAct=0
|
|
1002
|
+
[8,0,0,0,0,0]3
|
|
1003
|
+
connAct=0
|
|
1004
|
+
[9,0,0,0,0,0]3
|
|
1005
|
+
connAct=0
|
|
1006
|
+
[10,0,0,0,0,0]3
|
|
1007
|
+
connAct=0
|
|
1008
|
+
[error]0
|
|
1009
|
+
|
|
1010
|
+
'''
|
|
1011
|
+
|
|
1012
|
+
class TPLinkMRClientTest(TPLinkMRClient):
|
|
1013
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
1014
|
+
return 200, response
|
|
1015
|
+
|
|
1016
|
+
client = TPLinkMRClientTest('', '')
|
|
1017
|
+
status = client.get_vpn_status()
|
|
1018
|
+
|
|
1019
|
+
self.assertIsInstance(status, VPNStatus)
|
|
1020
|
+
self.assertEqual(status.openvpn_enable, True)
|
|
1021
|
+
self.assertEqual(status.pptpvpn_enable, False)
|
|
1022
|
+
self.assertEqual(status.openvpn_clients_total, 2)
|
|
1023
|
+
self.assertEqual(status.pptpvpn_clients_total, 0)
|
|
1024
|
+
|
|
1025
|
+
def test_set_vpn(self) -> None:
|
|
1026
|
+
response = '''
|
|
1027
|
+
[error]0
|
|
1028
|
+
|
|
1029
|
+
'''
|
|
1030
|
+
|
|
1031
|
+
check_url = ''
|
|
1032
|
+
check_data = ''
|
|
1033
|
+
|
|
1034
|
+
class TPLinkMRClientTest(TPLinkMRClient):
|
|
1035
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
1036
|
+
nonlocal check_url, check_data
|
|
1037
|
+
check_url = url
|
|
1038
|
+
check_data = data_str
|
|
1039
|
+
return 200, response
|
|
1040
|
+
|
|
1041
|
+
client = TPLinkMRClientTest('', '')
|
|
1042
|
+
client.set_vpn(VPN.OPEN_VPN, True)
|
|
1043
|
+
|
|
1044
|
+
self.assertIn('http:///cgi_gdpr?_=', check_url)
|
|
1045
|
+
self.assertEqual(check_data, '2\r\n[OPENVPN#0,0,0,0,0,0#0,0,0,0,0,0]0,1\r\nenable=1\r\n')
|
|
1046
|
+
|
|
867
1047
|
|
|
868
1048
|
if __name__ == '__main__':
|
|
869
1049
|
main()
|