Merge pull request #103 from quentinmit/ros718-empty

Add support for RouterOS 7.18's `!empty` reply word
This commit is contained in:
Jakub Gocławski 2025-03-06 16:44:02 +01:00 committed by GitHub
commit d05c0b13ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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']