test_bower.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Alexander Pyatkin <asp@thexyz.net
  4. """
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import salt libs
  8. import salt.utils.json
  9. import salt.utils.path
  10. # Import Salt Testing libs
  11. from tests.support.case import ModuleCase
  12. from tests.support.helpers import destructiveTest
  13. from tests.support.mixins import SaltReturnAssertsMixin
  14. from tests.support.unit import skipIf
  15. @skipIf(salt.utils.path.which("bower") is None, "bower not installed")
  16. class BowerStateTest(ModuleCase, SaltReturnAssertsMixin):
  17. @destructiveTest
  18. @skipIf(True, "SLOWTEST skip")
  19. def test_bower_installed_removed(self):
  20. """
  21. Basic test to determine if Bower package was successfully installed and
  22. removed.
  23. """
  24. ret = self.run_state("file.directory", name="/salt_test_bower_1", makedirs=True)
  25. self.assertSaltTrueReturn(ret)
  26. ret = self.run_state(
  27. "bower.installed", name="underscore", dir="/salt_test_bower_1"
  28. )
  29. self.assertSaltTrueReturn(ret)
  30. ret = self.run_state(
  31. "bower.removed", name="underscore", dir="/salt_test_bower_1"
  32. )
  33. self.assertSaltTrueReturn(ret)
  34. ret = self.run_state("file.absent", name="/salt_test_bower_1")
  35. self.assertSaltTrueReturn(ret)
  36. @destructiveTest
  37. @skipIf(True, "SLOWTEST skip")
  38. def test_bower_installed_pkgs(self):
  39. """
  40. Basic test to determine if Bower package successfully installs multiple
  41. packages.
  42. """
  43. ret = self.run_state("file.directory", name="/salt_test_bower_2", makedirs=True)
  44. self.assertSaltTrueReturn(ret)
  45. ret = self.run_state(
  46. "bower.installed",
  47. name="test",
  48. dir="/salt_test_bower_2",
  49. pkgs=["numeral", "underscore"],
  50. )
  51. self.assertSaltTrueReturn(ret)
  52. ret = self.run_state("file.absent", name="/salt_test_bower_2")
  53. self.assertSaltTrueReturn(ret)
  54. @destructiveTest
  55. @skipIf(True, "SLOWTEST skip")
  56. def test_bower_installed_from_file(self):
  57. ret = self.run_state("file.directory", name="/salt_test_bower_3", makedirs=True)
  58. self.assertSaltTrueReturn(ret)
  59. bower_json = salt.utils.json.dumps(
  60. {
  61. "name": "salt_test_bower_3",
  62. "dependencies": {"numeral": "~1.5.3", "underscore": "~1.7.0"},
  63. }
  64. )
  65. ret = self.run_state(
  66. "file.managed", name="/salt_test_bower_3/bower.json", contents=bower_json
  67. )
  68. self.assertSaltTrueReturn(ret)
  69. ret = self.run_state("bower.bootstrap", name="/salt_test_bower_3")
  70. self.assertSaltTrueReturn(ret)
  71. ret = self.run_state("file.absent", name="/salt_test_bower_3")
  72. self.assertSaltTrueReturn(ret)