From 347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 16 Jun 2023 13:03:18 +0200 Subject: Adding upstream version 2.3~rc1. Signed-off-by: Daniel Baumann --- test/test-avahi.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/test-avahi.py') 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() -- cgit v1.2.3