__init__.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """
  2. Tests the functionality of each provider implementation against registered test cases.
  3. These tests require that provider credentials are set as environment variables, as required for
  4. each provider.
  5. Since the tests exercise the cloudbridge interfaces, and there are multiple implementations of these
  6. interfaces, for m interfaces and n implementation, exercising all interfaces means that m*n test case
  7. classes are needed. Otherwise, the standard test runners such as unittest and nose2 do not correctly
  8. pick up the tests.
  9. To avoid an explosion of repetitive test cases, the ProviderTestCaseGenerator class will
  10. automatically generate a new Python class for each combination of test and provider. The
  11. load_tests protocol (https://docs.python.org/2/library/unittest.html#load-tests-protocol)
  12. is used to aid test discovery.
  13. Use ``python setup.py test`` to run these unit tests. (alternatively,use
  14. ``python -m unittest test``)
  15. All test cases need to be registered below, and available providers will be discovered through
  16. the ProviderFactory. Test Cases must not inherit from unittest.TestCase, to avoid confusing
  17. unittest and nose2's automatic discovery.
  18. (The test generator will automatically add unittest.TestCase as a base class to each combination)
  19. """
  20. from test.helpers import ProviderTestCaseGenerator
  21. from test.test_compute_service import ProviderComputeServiceTestCase
  22. from test.test_provider_image_service import ProviderImageServiceTestCase
  23. from test.test_provider_interface import ProviderInterfaceTestCase
  24. from test.test_provider_security_service import ProviderSecurityServiceTestCase
  25. PROVIDER_TESTS = [
  26. ProviderInterfaceTestCase,
  27. ProviderSecurityServiceTestCase,
  28. ProviderComputeServiceTestCase,
  29. # ProviderImageServiceTestCase
  30. ]
  31. def load_tests(loader=None, tests=None, pattern=None):
  32. """
  33. This function is required to aid the load_tests protocol
  34. (https://docs.python.org/2/library/unittest.html#load-tests-protocol)
  35. """
  36. return ProviderTestCaseGenerator(PROVIDER_TESTS).generate_tests()