test_lxd_profile.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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", name="test-profile",
  13. )
  14. def test_02__create_profile(self):
  15. self.run_state(
  16. "lxd_profile.absent", name="test-profile",
  17. )
  18. ret = self.run_state(
  19. "lxd_profile.present",
  20. name="test-profile",
  21. config=[{"key": "boot.autostart", "value": 1}],
  22. )
  23. name = "lxd_profile_|-test-profile_|-test-profile_|-present"
  24. self.assertSaltTrueReturn(ret)
  25. assert name in ret
  26. assert ret[name]["changes"] == {
  27. "created": 'Profile "test-profile" has been created'
  28. }
  29. def test_03__change_profile(self):
  30. self.run_state(
  31. "lxd_profile.present",
  32. name="test-profile",
  33. config=[{"key": "boot.autostart", "value": 1}],
  34. )
  35. ret = self.run_state(
  36. "lxd_profile.present",
  37. name="test-profile",
  38. config=[
  39. {"key": "boot.autostart", "value": 1},
  40. {"key": "security.privileged", "value": "1"},
  41. ],
  42. )
  43. name = "lxd_profile_|-test-profile_|-test-profile_|-present"
  44. self.assertSaltTrueReturn(ret)
  45. assert name in ret
  46. assert ret[name]["changes"]["config"] == {
  47. "security.privileged": 'Added config key "security.privileged" = "1"'
  48. }
  49. def test_04__delete_profile(self):
  50. self.run_state(
  51. "lxd_profile.present",
  52. name="test-profile",
  53. config=[{"key": "boot.autostart", "value": 1}],
  54. )
  55. ret = self.run_state("lxd_profile.absent", name="test-profile",)
  56. name = "lxd_profile_|-test-profile_|-test-profile_|-absent"
  57. self.assertSaltTrueReturn(ret)
  58. assert name in ret
  59. assert ret[name]["changes"] == {
  60. "removed": 'Profile "test-profile" has been deleted.'
  61. }