Skip to content

Commit

Permalink
Merge pull request #155 from glimchb/main
Browse files Browse the repository at this point in the history
test: more avahi tests
  • Loading branch information
martin-belanger authored Jun 10, 2022
2 parents 44dbd8f + 6f0345a commit 8c4c702
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 8c4c702

Please sign in to comment.