testplugin.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  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. # A test plugin. It does mostly nothing, just provides a function we can
  16. # recognize from the test. However, it looks like a real plugin, with the
  17. # (almost) correct interface, even when it's not used.
  18. class MockSpec:
  19. """Mock spec, contains no data, it can only provide it's name.
  20. It'll not really be used for anything."""
  21. def get_module_name(self):
  22. return "mock_config_plugin"
  23. def mock_check_config(config):
  24. """Mock function to check config. Does nothing, only returns
  25. an "error" string to indicate it's this one."""
  26. return "Mock config plugin"
  27. def load():
  28. """When a plugin is loaded, this is called to provide the spec and
  29. checking function."""
  30. return (MockSpec(), mock_check_config)