8
8
# *****************************************************************************
9
9
10
10
from datetime import datetime , timedelta
11
+ import uuid
11
12
import pytest
12
13
import testUtils
14
+ from wiotp .sdk .exceptions import ApiException
13
15
14
16
15
- @pytest .mark .skip (reason = "API currently unavailable (503)" )
16
17
class TestClientConnectivityStatus (testUtils .AbstractTest ):
17
18
18
19
# =========================================================================
@@ -21,25 +22,118 @@ class TestClientConnectivityStatus(testUtils.AbstractTest):
21
22
# These all need to be rewritten -- hard to do while the API is broken tho :/
22
23
# =========================================================================
23
24
24
- def testGetClientConnectionStates (self ):
25
- response = self .appClient .registry .connectionStatus .getClientStates ()
26
- assert response != None
27
- assert "results" in response
28
-
29
- def testGetConnectedClientConnectionStates (self ):
30
- response = self .appClient .registry .connectionStatus .getConnectedClientStates ()
31
- assert response != None
32
- assert "results" in response
33
-
34
- def testGetClientConnectionState (self ):
35
- # gets the connection state of a particular client id, returns 404 if client id is not found
36
- response = self .appClient .registry .connectionStatus .getState ("fakeId" )
37
- assert response != None
38
- assert response ["exception" ]["properties" ] == ["fakeId" ]
39
-
40
- def testGetRecentClientConnectionStates (self ):
41
- # checks for clients that have connected in the last two days
42
- iso8601Date = datetime .now () - timedelta (days = 2 )
43
- response = self .appClient .registry .connectionStatus .getRecentConnectionClientStates (iso8601Date .isoformat ())
44
- assert response != None
45
- assert "results" in response
25
+ # def testGetClientConnectionStates(self):
26
+ # response = self.appClient.registry.connectionStatus.getClientStates()
27
+ # assert response != None
28
+ # assert "results" in response
29
+
30
+ # def testGetConnectedClientConnectionStates(self):
31
+ # response = self.appClient.registry.connectionStatus.getConnectedClientStates()
32
+ # assert response != None
33
+ # assert "results" in response
34
+
35
+ # def testGetClientConnectionState(self):
36
+ # gets the connection state of a particular client id, returns 404 if client id is not found
37
+ # response = self.appClient.registry.connectionStatus.getState("fakeId")
38
+ # assert response != None
39
+ # assert response["exception"]["properties"] == ["fakeId"]
40
+
41
+ # def testGetRecentClientConnectionStates(self):
42
+ # checks for clients that have connected in the last two days
43
+ # iso8601Date = datetime.now() - timedelta(days=2)
44
+ # response = self.appClient.registry.connectionStatus.getRecentConnectionClientStates(iso8601Date.isoformat())
45
+ # assert response != None
46
+ # assert "results" in response
47
+
48
+ def testConnectionStatusContainsTrueValue (self ):
49
+ try :
50
+ key = 15
51
+ connectionStatusContains = self .appClient .registry .connectionStatus .__contains__ (key )
52
+ assert True
53
+ except :
54
+ assert False == True
55
+
56
+ def testConnectionStatusContainsAPIException (self ):
57
+ with pytest .raises (ApiException ) as e :
58
+ key = "fff/kdk/f?"
59
+ connectionStatusContains = self .appClient .registry .connectionStatus .__contains__ (key )
60
+ assert e
61
+
62
+ def testConnectionStatusGetItemValue (self ):
63
+ try :
64
+ key = 15
65
+ connectionStatusGetItem = self .appClient .registry .connectionStatus .__getitem__ (key )
66
+ assert False == True
67
+ except :
68
+ assert True
69
+
70
+ def testConnectionStatusIter (self ):
71
+ try :
72
+ deviceIter = self .appClient .registry .connectionStatus .__iter__ ()
73
+ assert True
74
+ except :
75
+ assert False == True
76
+
77
+ def testConnectionStatusGetItemError (self ):
78
+ with pytest .raises (KeyError ) as e :
79
+ key = 1
80
+ test = self .appClient .registry .connectionStatus .__getitem__ (key )
81
+ assert ("No status avaliable for client %s" % (key )) in str (e .value )
82
+
83
+ def testConnectionStatusMissingDeviceError (self ):
84
+ with pytest .raises (KeyError ) as e :
85
+ key = "k"
86
+ test = self .appClient .registry .connectionStatus .__missing__ (key )
87
+ assert ("No status avaliable for client %s" % (key )) in str (e .value )
88
+
89
+ def testConnectionStatusSetItemError (self ):
90
+ with pytest .raises (Exception ) as e :
91
+ test = self .appClient .registry .connectionStatus .__setitem__ ("s" , 1 )
92
+ assert "Unsupported operation" in str (e .value )
93
+
94
+ def testConnectionStatusDelItemError (self ):
95
+ with pytest .raises (Exception ) as e :
96
+ message = self .appClient .registry .connectionStatus .__delitem__ (1 )
97
+ assert "Unsupported operation" in str (e .value )
98
+
99
+ def testConnectionStatusFindTypeIdValue (self ):
100
+ deviceTypeId = str (uuid .uuid4 ())
101
+ try :
102
+ deviceTypeTest = self .appClient .registry .connectionStatus .find (typeId = deviceTypeId )
103
+ assert True # It has successfully inputed the values into IterableClientStatusList
104
+ except :
105
+ assert False == True # It has failed to input the values into IterableClientStatusList
106
+
107
+ def testConnectionStatusFindDeviceIdValue (self ):
108
+ deviceTypeId = str (uuid .uuid4 ())
109
+ try :
110
+ deviceTypeTest = self .appClient .registry .connectionStatus .find (deviceId = "Test" )
111
+ assert True # It has successfully inputed the values into IterableClientStatusList
112
+ except :
113
+ assert False == True # It has failed to input the values into IterableClientStatusList
114
+
115
+ def testConnectionStatusFindConnectionStatusValues (self ):
116
+ deviceTypeId = str (uuid .uuid4 ())
117
+ try :
118
+ deviceTypeTest = self .appClient .registry .connectionStatus .find (connectionStatus = "connected" )
119
+ assert True # It has successfully inputed the values into IterableClientStatusList
120
+ except :
121
+ assert False == True # It has failed to input the values into IterableClientStatusList
122
+
123
+ def testConnectionStatusFindConnectedAfterValues (self ):
124
+ deviceTypeId = str (uuid .uuid4 ())
125
+ try :
126
+ deviceTypeTest = self .appClient .registry .connectionStatus .find (connectedAfter = 100 )
127
+ assert True # It has successfully inputed the values into IterableClientStatusList
128
+ except :
129
+ assert False == True # It has failed to input the values into IterableClientStatusList
130
+
131
+ def testConnectionStatusFindParametersValues (self ):
132
+ deviceTypeId = str (uuid .uuid4 ())
133
+ try :
134
+ deviceTypeTest = self .appClient .registry .connectionStatus .find (
135
+ typeId = deviceTypeId , deviceId = "Test" , connectionStatus = "connected" , connectedAfter = 100
136
+ )
137
+ assert True # It has successfully inputed the values into IterableClientStatusList
138
+ except :
139
+ assert False == True # It has failed to input the values into IterableClientStatusList
0 commit comments