test_oneandone.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: :email:`Amel Ajdinovic <amel@stackpointcloud.com>`
  4. """
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Testing Libs
  8. from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest
  9. from tests.support.unit import skipIf
  10. # Import Third-Party Libs
  11. try:
  12. from oneandone.client import OneAndOneService # pylint: disable=unused-import
  13. HAS_ONEANDONE = True
  14. except ImportError:
  15. HAS_ONEANDONE = False
  16. @skipIf(HAS_ONEANDONE is False, "salt-cloud requires >= 1and1 1.2.0")
  17. class OneAndOneTest(CloudTest):
  18. """
  19. Integration tests for the 1and1 cloud provider
  20. """
  21. PROVIDER = "oneandone"
  22. REQUIRED_PROVIDER_CONFIG_ITEMS = ("api_token",)
  23. def test_list_images(self):
  24. """
  25. Tests the return of running the --list-images command for 1and1
  26. """
  27. image_list = self.run_cloud("--list-images {0}".format(self.PROVIDER_NAME))
  28. self.assertIn("coreOSimage", [i.strip() for i in image_list])
  29. def test_instance(self):
  30. """
  31. Test creating an instance on 1and1
  32. """
  33. # check if instance with salt installed returned
  34. ret_str = self.run_cloud(
  35. "-p oneandone-test {0}".format(self.instance_name), timeout=TIMEOUT
  36. )
  37. self.assertInstanceExists(ret_str)
  38. self.assertDestroyInstance()