test_oneandone.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 CloudTest, TIMEOUT
  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(
  29. 'coreOSimage',
  30. [i.strip() for i in image_list]
  31. )
  32. def test_instance(self):
  33. '''
  34. Test creating an instance on 1and1
  35. '''
  36. # check if instance with salt installed returned
  37. ret_str = self.run_cloud('-p oneandone-test {0}'.format(self.instance_name), timeout=TIMEOUT)
  38. self.assertInstanceExists(ret_str)
  39. self.assertDestroyInstance()