1
0

test_spm.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # -*- coding: utf-8 -*-
  2. # Import python libs
  3. from __future__ import absolute_import
  4. import os
  5. # Import Salt Testing libs
  6. from tests.support.case import ShellCase, SPMCase
  7. import pytest
  8. @pytest.mark.windows_whitelisted
  9. class SPMTest(ShellCase, SPMCase):
  10. '''
  11. Test spm script
  12. '''
  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. 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. def test_spm_assume_yes(self):
  30. '''
  31. test spm install with -y arg
  32. '''
  33. config = self._spm_config(assume_yes=False)
  34. self._spm_build_files(config)
  35. spm_file = os.path.join(config['spm_build_dir'],
  36. 'apache-201506-2.spm')
  37. build = self.run_spm('build {0} -c {1}'.format(self.formula_dir,
  38. self._tmp_spm))
  39. install = self.run_spm('install {0} -c {1} -y'.format(spm_file,
  40. self._tmp_spm))
  41. self.assertTrue(os.path.exists(os.path.join(config['formula_path'],
  42. 'apache', 'apache.sls')))
  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'],
  50. 'apache-201506-2.spm')
  51. build = self.run_spm('build {0} -c {1}'.format(self.formula_dir,
  52. self._tmp_spm))
  53. install = self.run_spm('install {0} -c {1} -y'.format(spm_file,
  54. self._tmp_spm))
  55. self.assertTrue(os.path.exists(os.path.join(config['formula_path'],
  56. 'apache', 'apache.sls')))
  57. # check if it forces the install after its already been installed it
  58. install = self.run_spm('install {0} -c {1} -y -f'.format(spm_file,
  59. self._tmp_spm))
  60. self.assertEqual(['... installing apache'], install)