Skip to content

Commit

Permalink
test: more avahi tests
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jun 10, 2022
1 parent 40c3d56 commit 6f0345a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/test-avahi.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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()

0 comments on commit 6f0345a

Please sign in to comment.