From 6f0345aa15ee35ebc8c510c1a1f81272fa6ced5b Mon Sep 17 00:00:00 2001 From: Boris Glimcher Date: Fri, 10 Jun 2022 16:51:59 +0300 Subject: [PATCH] test: more avahi tests Signed-off-by: Boris Glimcher --- test/test-avahi.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/test-avahi.py b/test/test-avahi.py index 1fd3ab3..13ce85a 100755 --- a/test/test-avahi.py +++ b/test/test-avahi.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 import os import unittest -from staslib import avahi +from staslib import stas, avahi import dasbus.connection class Test(unittest.TestCase): @@ -12,6 +12,17 @@ def test_new(self): srv = avahi.Avahi(sysbus, lambda:"ok") self.assertEqual(srv.info(), {'avahi wake up timer': '60.0s [off]', 'service types': [], 'services': {}}) self.assertEqual(srv.get_controllers(), []) + self.assertEqual(srv._on_kick_avahi(), True) + with self.assertLogs(logger=stas.LOG, level='INFO') as captured: + srv._avahi_available(None) + self.assertEqual(len(captured.records), 1) + self.assertEqual(captured.records[0].getMessage(), "avahi-daemon service available, zeroconf supported.") + with self.assertLogs(logger=stas.LOG, level='WARN') as captured: + srv._avahi_unavailable(None) + self.assertEqual(len(captured.records), 1) + self.assertEqual(captured.records[0].getMessage(), "avahi-daemon not available, zeroconf not supported.") + srv.kill() + self.assertEqual(srv.info(), {'avahi wake up timer': 'None', 'service types': [], 'services': {}}) if __name__ == '__main__': unittest.main()