summaryrefslogtreecommitdiffstats
path: root/test/test-avahi.py
diff options
context:
space:
mode:
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()