test_avahi_announce.py 1.2 KB

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