tsig_keys_test.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (C) 2011 Internet Systems Consortium.
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  8. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  9. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  10. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  12. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  14. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. # Make sure we can load the module, put it into path
  16. import sys
  17. import os
  18. sys.path.extend(os.environ["B10_TEST_PLUGIN_DIR"].split(':'))
  19. import tsig_keys
  20. import unittest
  21. import isc.config.module_spec
  22. class TSigKeysTest(unittest.TestCase):
  23. def test_load(self):
  24. """
  25. Checks the entry point returns the correct values.
  26. """
  27. (spec, check) = tsig_keys.load()
  28. # It returns the checking function
  29. self.assertEqual(check, tsig_keys.check)
  30. # The plugin stores it's spec
  31. self.assertEqual(spec, tsig_keys.spec)
  32. def test_spec(self):
  33. """
  34. Checks the spec is looking sane (doesn't do really deep check here).
  35. """
  36. spec = tsig_keys.spec
  37. # In python, we don't generally check the type of something, because
  38. # of the duck typing.
  39. # But this is unittest, so we check it does what we intend and
  40. # supplying that's behaving the same but is different is not our
  41. # intention
  42. self.assertTrue(isinstance(spec, isc.config.module_spec.ModuleSpec))
  43. # Correct name
  44. self.assertEqual("tsig_keys", spec.get_module_name())
  45. # There are no commands, nobody would handle them anyway
  46. self.assertEqual([], spec.get_commands_spec())
  47. # There's some nonempty configuration
  48. self.assertNotEqual({}, spec.get_config_spec())
  49. if __name__ == '__main__':
  50. unittest.main()