test_spm.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import
  3. import os
  4. import pytest
  5. from tests.support.case import ShellCase, SPMCase
  6. from tests.support.helpers import slowTest
  7. @pytest.mark.windows_whitelisted
  8. class SPMTest(ShellCase, SPMCase):
  9. """
  10. Test spm script
  11. """
  12. @slowTest
  13. def test_spm_help(self):
  14. """
  15. test --help argument for spm
  16. """
  17. expected_args = ["--version", "--assume-yes", "--help"]
  18. output = self.run_spm("--help")
  19. for arg in expected_args:
  20. self.assertIn(arg, "".join(output))
  21. @slowTest
  22. def test_spm_bad_arg(self):
  23. """
  24. test correct output when bad argument passed
  25. """
  26. expected_args = ["--version", "--assume-yes", "--help"]
  27. output = self.run_spm("doesnotexist")
  28. for arg in expected_args:
  29. self.assertIn(arg, "".join(output))
  30. @slowTest
  31. def test_spm_assume_yes(self):
  32. """
  33. test spm install with -y arg
  34. """
  35. config = self._spm_config(assume_yes=False)
  36. self._spm_build_files(config)
  37. spm_file = os.path.join(config["spm_build_dir"], "apache-201506-2.spm")
  38. build = self.run_spm("build {0} -c {1}".format(self.formula_dir, self._tmp_spm))
  39. install = self.run_spm("install {0} -c {1} -y".format(spm_file, self._tmp_spm))
  40. self.assertTrue(
  41. os.path.exists(os.path.join(config["formula_path"], "apache", "apache.sls"))
  42. )
  43. @slowTest
  44. def test_spm_force(self):
  45. """
  46. test spm install with -f arg
  47. """
  48. config = self._spm_config(assume_yes=False)
  49. self._spm_build_files(config)
  50. spm_file = os.path.join(config["spm_build_dir"], "apache-201506-2.spm")
  51. build = self.run_spm("build {0} -c {1}".format(self.formula_dir, self._tmp_spm))
  52. install = self.run_spm("install {0} -c {1} -y".format(spm_file, self._tmp_spm))
  53. self.assertTrue(
  54. os.path.exists(os.path.join(config["formula_path"], "apache", "apache.sls"))
  55. )
  56. # check if it forces the install after its already been installed it
  57. install = self.run_spm(
  58. "install {0} -c {1} -y -f".format(spm_file, self._tmp_spm)
  59. )
  60. self.assertEqual(["... installing apache"], install)