1
0

test_bonjour_announce.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # coding: utf-8
  2. # Python libs
  3. from __future__ import absolute_import
  4. # Salt libs
  5. import salt.beacons.bonjour_announce as bonjour_announce
  6. from tests.support.mixins import LoaderModuleMockMixin
  7. # Salt testing libs
  8. from tests.support.unit import TestCase
  9. class BonjourAnnounceBeaconTestCase(TestCase, LoaderModuleMockMixin):
  10. """
  11. Test case for salt.beacons.avahi_announce
  12. """
  13. def setup_loader_modules(self):
  14. return {
  15. bonjour_announce: {
  16. "last_state": {},
  17. "last_state_extra": {"no_devices": False},
  18. }
  19. }
  20. def test_non_list_config(self):
  21. config = {}
  22. ret = bonjour_announce.validate(config)
  23. self.assertEqual(
  24. ret, (False, "Configuration for bonjour_announce beacon must be a list.")
  25. )
  26. def test_empty_config(self):
  27. config = [{}]
  28. ret = bonjour_announce.validate(config)
  29. self.assertEqual(
  30. ret,
  31. (
  32. False,
  33. "Configuration for bonjour_announce"
  34. " beacon must contain servicetype, port"
  35. " and txt items.",
  36. ),
  37. )