mirror of
https://github.com/socialwifi/RouterOS-api.git
synced 2025-08-31 23:20:05 +02:00
Remove support for ASCII resources.
This commit is contained in:
parent
9890e22cd9
commit
cd5665813d
3 changed files with 35 additions and 65 deletions
|
@ -8,14 +8,14 @@ except ImportError:
|
|||
from routeros_api import exceptions
|
||||
from routeros_api import api_communicator
|
||||
|
||||
class TestResponseSentence(TestCase):
|
||||
class TestCommunicator(TestCase):
|
||||
def test_login_call(self):
|
||||
base = mock.Mock()
|
||||
base.receive_sentence.return_value = [b'!done', b'=ret=some-hex',
|
||||
b'.tag=1']
|
||||
communicator = api_communicator.ApiCommunicator(base)
|
||||
response = communicator.call('/', 'login', include_done=True).get()
|
||||
self.assertEqual(response[0]['ret'], 'some-hex')
|
||||
self.assertEqual(response[0]['ret'], b'some-hex')
|
||||
|
||||
def test_normal_call(self):
|
||||
base = mock.Mock()
|
||||
|
@ -23,7 +23,7 @@ class TestResponseSentence(TestCase):
|
|||
[b'!done', b'.tag=1']]
|
||||
communicator = api_communicator.ApiCommunicator(base)
|
||||
response = communicator.call('/interface/', 'print').get()
|
||||
self.assertEqual(response, [{'x': 'y'}])
|
||||
self.assertEqual(response, [{'x': b'y'}])
|
||||
|
||||
def test_mixed_calls(self):
|
||||
base = mock.Mock()
|
||||
|
@ -35,17 +35,8 @@ class TestResponseSentence(TestCase):
|
|||
promise = communicator.call('/interface/', 'print')
|
||||
response2 = communicator.call('/interface/', 'print').get()
|
||||
response1 = promise.get()
|
||||
self.assertEqual(response1, [{'x1': 'y1'}])
|
||||
self.assertEqual(response2, [{'x2': 'y2'}])
|
||||
|
||||
def test_binary_call(self):
|
||||
base = mock.Mock()
|
||||
base.receive_sentence.side_effect = [[b'!re', b'=x=y', b'.tag=1'],
|
||||
[b'!done', b'.tag=1']]
|
||||
communicator = api_communicator.ApiCommunicator(base)
|
||||
promise = communicator.call('/file/', 'print', binary=True)
|
||||
response = promise.get()
|
||||
self.assertEqual(response, [{'x': b'y'}])
|
||||
self.assertEqual(response1, [{'x1': b'y1'}])
|
||||
self.assertEqual(response2, [{'x2': b'y2'}])
|
||||
|
||||
def test_error_call(self):
|
||||
base = mock.Mock()
|
||||
|
@ -69,7 +60,7 @@ class TestResponseSentence(TestCase):
|
|||
base = mock.Mock()
|
||||
base.receive_sentence.return_value = [b'!done', b'.tag=1']
|
||||
communicator = api_communicator.ApiCommunicator(base)
|
||||
communicator.call('/interface/', 'set', {'x': 'y'})
|
||||
communicator.call('/interface/', 'set', {'x': b'y'})
|
||||
base.send_sentence.assert_called_once_with(
|
||||
[b'/interface/set', b'=x=y', b'.tag=1'])
|
||||
|
||||
|
@ -84,16 +75,3 @@ class TestResponseSentence(TestCase):
|
|||
communicator.call('/interface/', 'print').get()
|
||||
self.assertRaises(exceptions.RouterOsApiCommunicationError,
|
||||
promise.get)
|
||||
|
||||
def test_mixed_binary_and_ascii_calls(self):
|
||||
base = mock.Mock()
|
||||
base.receive_sentence.side_effect = [[b'!re', b'=x1=y1', b'.tag=1'],
|
||||
[b'!re', b'=x2=y2', b'.tag=2'],
|
||||
[b'!done', b'.tag=1'],
|
||||
[b'!done', b'.tag=2']]
|
||||
communicator = api_communicator.ApiCommunicator(base)
|
||||
promise = communicator.call('/interface/', 'print', binary=True)
|
||||
response2 = communicator.call('/interface/', 'print').get()
|
||||
response1 = promise.get()
|
||||
self.assertEqual(response1, [{'x1': b'y1'}])
|
||||
self.assertEqual(response2, [{'x2': 'y2'}])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue