def test_create_transport_raises_connection_error(self): for error in (SOCKET_ERROR, SOCKET_TIMEOUT): with patch('routeros.create_connection') as connection: connection.side_effect = error with self.assertRaises(ConnectionError): create_transport(host='127.0.0.1', port=9099)
def test_create_transport_calls_socket(self): with patch('routeros.Socket') as socket: with patch('routeros.create_connection') as connection: a = create_transport(host='127.0.0.1', port=9099) socket.assert_called_once_with(sock=connection.return_value)
def test_create_transport_calls_create_connection(self): with patch('routeros.create_connection') as connection: create_transport(host='127.0.0.1', port=9099) connection.assert_called_once_with(address=('127.0.0.1', 9099), timeout=10)