8000 tests corrections after new changes · librarysteve/lib-python@47ed3d9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 47ed3d9

Browse files
committed
tests corrections after new changes
1 parent 0bd9913 commit 47ed3d9

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

test/test_blynk_connection.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import time
44
import pytest
55
import socket
6-
from blynklib import Connection, BlynkException
6+
from blynklib import Connection, BlynkError
7< 10000 /code>7

88

99
class TestBlynkConnection:
@@ -128,10 +128,10 @@ def test_get_socket(self, cb, mocker):
128128

129129
def test_get_socket_exception(self, cb, mocker):
130130
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:
133133
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)
135135

136136
def test_authenticate(self, cb, mocker):
137137
with mocker.patch.object(cb, 'send', return_value=None):
@@ -142,37 +142,37 @@ def test_authenticate(self, cb, mocker):
142142
def test_authenticate_invalid_auth_token(self, cb, mocker):
143143
with mocker.patch.object(cb, 'send', return_value=None):
144144
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:
146146
cb._authenticate()
147-
assert 'Invalid Auth Token' in str(b_exc)
147+
assert 'Invalid Auth Token' in str(b_err)
148148

149149
def test_authenticate_not_ok_status(self, cb, mocker):
150150
with mocker.patch.object(cb, 'send', return_value=None):
151151
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:
153153
cb._authenticate()
154-
assert 'Auth stage failed. Status=25' in str(b_exc)
154+
assert 'Auth stage failed. Status=25' in str(b_err)
155155

156156
def test_authenticate_timeout(self, cb, mocker):
157157
with mocker.patch.object(cb, 'send', return_value=None):
158158
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:
160160
cb._authenticate()
161-
assert 'Auth stage timeout' in str(b_exc)
161+
assert 'Auth stage timeout' in str(b_err)
162162

163163
def test_set_heartbeat_timeout(self, cb, mocker):
164164
with mocker.patch.object(cb, 'send', return_value=None):
165165
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:
167167
cb._set_heartbeat()
168-
assert 'Heartbeat stage timeout' in str(b_exc)
168+
assert 'Heartbeat stage timeout' in str(b_err)
169169

170170
def test_set_heartbeat_error_status(self, cb, mocker):
171171
with mocker.patch.object(cb, 'send', return_value=None):
172172
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:
174174
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)
176176

177177
def test_set_heartbeat_positive(self, cb, mocker):
178178
with mocker.patch.object(cb, 'send', return_value=None):

test/test_blynk_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import print_function
33
import socket
44
import pytest
5-
from blynklib import Blynk, BlynkException
5+
from blynklib import Blynk, BlynkError
66

77

88
class TestBlynk:
@@ -23,7 +23,7 @@ def test_connect(self, bl, mocker):
2323
def test_connect_exception(self, bl, mocker):
2424
with mocker.patch.object(bl, 'connected', return_value=False):
2525
with mocker.patch.object(bl, '_get_socket', return_value=None):
26-
with mocker.patch.object(bl, '_authenticate', side_effect=BlynkException()):
26+
with mocker.patch.object(bl, '_authenticate', side_effect=BlynkError()):
2727
with mocker.patch.object(bl, 'disconnect', return_value=None):
2828
with mocker.patch('time.sleep', return_value=None):
2929
mocker.spy(bl, 'disconnect')

test/test_blynk_protocol.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import sys
33
import pytest
4-
from blynklib import Protocol, BlynkException
4+
from blynklib import Protocol, BlynkError
55

66

77
class TestBlynkProtocol:
@@ -60,16 +60,16 @@ def test_parse_response_msg_hw(self, pb):
6060
def test_parse_response_msg_id_0(self, pb):
6161
data = b'\x14\x00\x00\x00\x13test\x001234\x00745\x00abcde'
6262
msg_buffer = 100
63-
with pytest.raises(BlynkException) as exc:
63+
with pytest.raises(BlynkError) as b_err:
6464
pb.parse_response(data, msg_buffer)
65-
assert 'invalid msg_id == 0' == str(exc.value)
65+
assert 'invalid msg_id == 0' == str(b_err.value)
6666

6767
def test_parse_response_more_data_than_buffer(self, pb):
6868
data = b'\x14\x00\x02\x00\x13test\x001234\x00745\x00abcde'
6969
msg_buffer = 10
70-
with pytest.raises(BlynkException) as exc:
70+
with pytest.raises(BlynkError) as b_err:
7171
pb.parse_response(data, msg_buffer)
72-
assert 'Command too long' in str(exc.value)
72+
assert 'Command too long' in str(b_err.value)
7373

7474
def test_parse_response_msg_ping(self, pb):
7575
data = b'\x06\x00\x04\x00\x13test\x001234\x00745\x00abcde'
@@ -87,9 +87,9 @@ def test_parse_response_corrupted_data(self, pb):
8787
def test_parse_response_wrong_msg_type(self, pb):
8888
data = b'\x86\x00\x04\x00\x13test\x001234\x00745\x00abcde'
8989
msg_buffer = 100
90-
with pytest.raises(BlynkException) as exc:
90+
with pytest.raises(BlynkError) as b_err:
9191
pb.parse_response(data, msg_buffer)
92-
assert "Unknown message type: '134'" in str(exc.value)
92+
assert "Unknown message type: '134'" in str(b_err.value)
9393

9494
def test_parse_response_msg_hw_unicode(self, pb):
9595
data = b'\x14\x00\x02\x00\x04\xd1\x91\xd0\xb6'
@@ -99,7 +99,7 @@ def test_parse_response_msg_hw_unicode(self, pb):
9999

100100
def test_heartbeat_msg(self, pb):
101101
result = pb.heartbeat_msg(20, 2048)
102-
assert result == b'\x11\x00\x02\x00+ver\x000.1.1\x00buff-in\x002048\x00h-beat\x0020\x00dev\x00python'
102+
assert result == b'\x11\x00\x02\x00+ver\x000.2.4\x00buff-in\x002048\x00h-beat\x0020\x00dev\x00python'
103103

104104
def test_login_msg(self, pb):
105105
result = pb.login_msg('1234')

0 commit comments

Comments
 (0)
0