kopia lustrzana https://github.com/glidernet/python-ogn-client
adapt client.py unit tests with new run strict arg
rodzic
a77c55ce24
commit
08d5b6b4d9
|
@ -25,7 +25,7 @@ class AprsClientTest(unittest.TestCase):
|
||||||
client.connect()
|
client.connect()
|
||||||
client.sock.send.assert_called_once_with('user testuser pass -1 vers {} {}\n'.format(
|
client.sock.send.assert_called_once_with('user testuser pass -1 vers {} {}\n'.format(
|
||||||
APRS_APP_NAME, APRS_APP_VER).encode('ascii'))
|
APRS_APP_NAME, APRS_APP_VER).encode('ascii'))
|
||||||
client.sock.makefile.assert_called_once_with('rw')
|
client.sock.makefile.assert_called_once_with('rb')
|
||||||
|
|
||||||
@mock.patch('ogn.client.client.socket')
|
@mock.patch('ogn.client.client.socket')
|
||||||
def test_connect_client_defined_filter(self, mock_socket):
|
def test_connect_client_defined_filter(self, mock_socket):
|
||||||
|
@ -33,7 +33,7 @@ class AprsClientTest(unittest.TestCase):
|
||||||
client.connect()
|
client.connect()
|
||||||
client.sock.send.assert_called_once_with('user testuser pass -1 vers {} {} filter r/50.4976/9.9495/100\n'.format(
|
client.sock.send.assert_called_once_with('user testuser pass -1 vers {} {} filter r/50.4976/9.9495/100\n'.format(
|
||||||
APRS_APP_NAME, APRS_APP_VER).encode('ascii'))
|
APRS_APP_NAME, APRS_APP_VER).encode('ascii'))
|
||||||
client.sock.makefile.assert_called_once_with('rw')
|
client.sock.makefile.assert_called_once_with('rb')
|
||||||
|
|
||||||
@mock.patch('ogn.client.client.socket')
|
@mock.patch('ogn.client.client.socket')
|
||||||
def test_disconnect(self, mock_socket):
|
def test_disconnect(self, mock_socket):
|
||||||
|
@ -53,18 +53,18 @@ class AprsClientTest(unittest.TestCase):
|
||||||
client.connect()
|
client.connect()
|
||||||
|
|
||||||
client.sock_file.readline = mock.MagicMock()
|
client.sock_file.readline = mock.MagicMock()
|
||||||
client.sock_file.readline.side_effect = ['Normal text blabla',
|
client.sock_file.readline.side_effect = [b'Normal text blabla',
|
||||||
'my weird character ¥',
|
b'my weird character \xc2\xa5',
|
||||||
UnicodeDecodeError('funnycodec', b'\x00\x00', 1, 2, 'This is just a fake reason!'),
|
UnicodeDecodeError('funnycodec', b'\x00\x00', 1, 2, 'This is just a fake reason!'),
|
||||||
'... show must go on',
|
b'... show must go on',
|
||||||
BrokenPipeError(),
|
BrokenPipeError(),
|
||||||
'... and on',
|
b'... and on',
|
||||||
ConnectionResetError(),
|
ConnectionResetError(),
|
||||||
'... and on',
|
b'... and on',
|
||||||
socket.error(),
|
socket.error(),
|
||||||
'... and on',
|
b'... and on',
|
||||||
'',
|
b'',
|
||||||
'... and on',
|
b'... and on',
|
||||||
KeyboardInterrupt()]
|
KeyboardInterrupt()]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -84,7 +84,7 @@ class AprsClientTest(unittest.TestCase):
|
||||||
client.connect()
|
client.connect()
|
||||||
|
|
||||||
client.sock_file.readline = mock.MagicMock()
|
client.sock_file.readline = mock.MagicMock()
|
||||||
client.sock_file.readline.side_effect = ['Normal text blabla',
|
client.sock_file.readline.side_effect = [b'Normal text blabla',
|
||||||
KeyboardInterrupt()]
|
KeyboardInterrupt()]
|
||||||
|
|
||||||
mock_time.side_effect = [0, 0, APRS_KEEPALIVE_TIME + 1, APRS_KEEPALIVE_TIME + 1]
|
mock_time.side_effect = [0, 0, APRS_KEEPALIVE_TIME + 1, APRS_KEEPALIVE_TIME + 1]
|
||||||
|
|
Ładowanie…
Reference in New Issue