3
3
import time
4
4
import pytest
5
5
import socket
6
- from blynklib import Connection , BlynkException
6
+ from blynklib import Connection , BlynkError
7<
10000
/code>
7
8
8
9
9
class TestBlynkConnection :
@@ -128,10 +128,10 @@ def test_get_socket(self, cb, mocker):
128
128
129
129
def test_get_socket_exception (self , cb , mocker ):
130
130
with mocker .patch ('socket.socket' ):
131
- with mocker .patch ('socket.getaddrinfo' , side_effect = BlynkException ('BE' )):
132
- with pytest .raises (BlynkException ) as b_exc :
131
+ with mocker .patch ('socket.getaddrinfo' , side_effect = BlynkError ('BE' )):
132
+ with pytest .raises (BlynkError ) as b_err :
133
133
cb ._get_socket ()
134
- assert 'Connection with the Blynk server failed: BE' in str (b_exc )
134
+ assert 'Connection with the Blynk server failed: BE' in str (b_err )
135
135
136
136
def test_authenticate (self , cb , mocker ):
137
137
with mocker .patch .object (cb , 'send' , return_value = None ):
@@ -142,37 +142,37 @@ def test_authenticate(self, cb, mocker):
142
142
def test_authenticate_invalid_auth_token (self , cb , mocker ):
143
143
with mocker .patch .object (cb , 'send' , return_value = None ):
144
144
with mocker .patch .object (cb , 'receive' , return_value = b'\x00 \x00 \x02 \x00 \x09 ' ):
145
- with pytest .raises (BlynkException ) as b_exc :
145
+ with pytest .raises (BlynkError ) as b_err :
146
146
cb ._authenticate ()
147
- assert 'Invalid Auth Token' in str (b_exc )
147
+ assert 'Invalid Auth Token' in str (b_err )
148
148
149
149
def test_authenticate_not_ok_status (self , cb , mocker ):
150
150
with mocker .patch .object (cb , 'send' , return_value = None ):
151
151
with mocker .patch .object (cb , 'receive' , return_value = b'\x00 \x00 \x02 \x00 \x19 ' ):
152
- with pytest .raises (BlynkException ) as b_exc :
152
+ with pytest .raises (BlynkError ) as b_err :
153
153
cb ._authenticate ()
154
- assert 'Auth stage failed. Status=25' in str (b_exc )
154
+ assert 'Auth stage failed. Status=25' in str (b_err )
155
155
156
156
def test_authenticate_timeout (self , cb , mocker ):
157
157
with mocker .patch .object (cb , 'send' , return_value = None ):
158
158
with mocker .patch .object (cb , 'receive' , return_value = None ):
159
- with pytest .raises (BlynkException ) as b_exc :
159
+ with pytest .raises (BlynkError ) as b_err :
160
160
cb ._authenticate ()
161
- assert 'Auth stage timeout' in str (b_exc )
161
+ assert 'Auth stage timeout' in str (b_err )
162
162
163
163
def test_set_heartbeat_timeout (self , cb , mocker ):
164
164
with mocker .patch .object (cb , 'send' , return_value = None ):
165
165
with mocker .patch .object (cb , 'receive' , return_value = None ):
166
- with pytest .raises (BlynkException ) as b_exc :
166
+ with pytest .raises (BlynkError ) as b_err :
167
167
cb ._set_heartbeat ()
168
- assert 'Heartbeat stage timeout' in str (b_exc )
168
+ assert 'Heartbeat stage timeout' in str (b_err )
169
169
170
170
def test_set_heartbeat_error_status (self , cb , mocker ):
171
171
with mocker .patch .object (cb , 'send' , return_value = None ):
172
172
with mocker .patch .object (cb , 'receive' , return_value = b'\x00 \x00 \x02 \x00 \x0e ' ):
173
- with pytest .raises (BlynkException ) as b_exc :
173
+ with pytest .raises (BlynkError ) as b_err :
174
174
cb ._set_heartbeat ()
175
- assert 'Set heartbeat returned code=14' in str (b_exc )
175
+ assert 'Set heartbeat returned code=14' in str (b_err )
176
176
177
177
def test_set_heartbeat_positive (self , cb , mocker ):
178
178
with mocker .patch .object (cb , 'send' , return_value = None ):
0 commit comments