1
0

test_lxd_profile.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Integration tests for the lxd states
  4. '''
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Lxd Test Case
  8. import tests.integration.states.test_lxd
  9. class LxdProfileTestCase(tests.integration.states.test_lxd.LxdTestCase):
  10. def tearDown(self):
  11. self.run_state(
  12. 'lxd_profile.absent',
  13. name='test-profile',
  14. )
  15. def test_02__create_profile(self):
  16. self.run_state(
  17. 'lxd_profile.absent',
  18. name='test-profile',
  19. )
  20. ret = self.run_state(
  21. 'lxd_profile.present',
  22. name='test-profile',
  23. config=[
  24. {'key': 'boot.autostart', 'value': 1},
  25. ],
  26. )
  27. name = 'lxd_profile_|-test-profile_|-test-profile_|-present'
  28. self.assertSaltTrueReturn(ret)
  29. assert name in ret
  30. assert ret[name]['changes'] == {'created': 'Profile "test-profile" has been created'}
  31. def test_03__change_profile(self):
  32. self.run_state(
  33. 'lxd_profile.present',
  34. name='test-profile',
  35. config=[
  36. {'key': 'boot.autostart', 'value': 1},
  37. ],
  38. )
  39. ret = self.run_state(
  40. 'lxd_profile.present',
  41. name='test-profile',
  42. config=[
  43. {'key': 'boot.autostart', 'value': 1},
  44. {'key': 'security.privileged', 'value': '1'},
  45. ],
  46. )
  47. name = 'lxd_profile_|-test-profile_|-test-profile_|-present'
  48. self.assertSaltTrueReturn(ret)
  49. assert name in ret
  50. assert ret[name]['changes']['config'] == {
  51. 'security.privileged': 'Added config key "security.privileged" = "1"'
  52. }
  53. def test_04__delete_profile(self):
  54. self.run_state(
  55. 'lxd_profile.present',
  56. name='test-profile',
  57. config=[
  58. {'key': 'boot.autostart', 'value': 1},
  59. ],
  60. )
  61. ret = self.run_state(
  62. 'lxd_profile.absent',
  63. name='test-profile',
  64. )
  65. name = 'lxd_profile_|-test-profile_|-test-profile_|-absent'
  66. self.assertSaltTrueReturn(ret)
  67. assert name in ret
  68. assert ret[name]['changes'] == {'removed': 'Profile "test-profile" has been deleted.'}