1
0

test_spm.py 2.4 KB

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