summaryrefslogtreecommitdiffstats
path: root/test/test-avahi.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-16 11:03:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-16 11:03:18 +0000
commit347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30 (patch)
tree44ae9f59984c8a36b93f29a729f10473653f9f19 /test/test-avahi.py
parentAdding upstream version 2.2.2. (diff)
downloadnvme-stas-347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30.tar.xz
nvme-stas-347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30.zip
Adding upstream version 2.3~rc1.upstream/2.3_rc1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test-avahi.py')
-rwxr-xr-xtest/test-avahi.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test-avahi.py b/test/test-avahi.py
index 3529104..1081947 100755
--- a/test/test-avahi.py
+++ b/test/test-avahi.py
@@ -36,6 +36,26 @@ class Test(unittest.TestCase):
srv.kill()
self.assertEqual(srv.info(), {'avahi wake up timer': 'None', 'service types': [], 'services': {}})
+ def test__txt2dict(self):
+ txt = [
+ list('NqN=Starfleet'.encode('utf-8')),
+ list('p=tcp'.encode('utf-8')),
+ ]
+ self.assertEqual(avahi._txt2dict(txt), {'nqn': 'Starfleet', 'p': 'tcp'})
+
+ txt = [
+ list('Nqn=Starfleet'.encode('utf-8')),
+ list('p='.encode('utf-8')), # Try with a missing value for p
+ list('blah'.encode('utf-8')), # Missing '='
+ list('='.encode('utf-8')), # Just '='
+ ]
+ self.assertEqual(avahi._txt2dict(txt), {'nqn': 'Starfleet', 'p': ''})
+
+ txt = [
+ [1000, ord('='), 123456], # Try with non printable characters
+ ]
+ self.assertEqual(avahi._txt2dict(txt), {})
+
if __name__ == '__main__':
unittest.main()