Add support for RouterOS 7.18's !empty reply word

See documentation at https://help.mikrotik.com/docs/spaces/ROS/pages/47579160/API#API-Replyword
This commit is contained in:
Quentin Smith 2025-03-05 01:15:07 -05:00
parent 5e7963fcfe
commit 68aaa5ace9
2 changed files with 9 additions and 1 deletions

View file

@ -3,7 +3,7 @@ import re
from routeros_api import exceptions
from routeros_api import query
response_re = re.compile(rb'^!(re|trap|fatal|done)$')
response_re = re.compile(rb'^!(re|trap|fatal|empty|done)$')
attribute_re = re.compile(rb'^=([^=]+)=(.*)$', re.DOTALL)
tag_re = re.compile(rb'^\.tag=(.*)$')

View file

@ -49,6 +49,14 @@ class TestCommunicator(TestCase):
self.assertRaises(exceptions.RouterOsApiCommunicationError,
promise.get)
def test_empty_call(self):
base = mock.Mock()
base.receive_sentence.side_effect = [[b'!empty', b'.tag=1'],
[b'!done', b'.tag=1']]
communicator = api_communicator.ApiCommunicator(base)
response = communicator.call('/file/', 'print').get()
self.assertEqual(response, [])
def test_query_call(self):
base = mock.Mock()
base.receive_sentence.return_value = [b'!done', b'.tag=1']