1
0

test_api.py 803 B

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import sys
  4. from salt.cli.api import SaltAPI
  5. from tests.support.helpers import slowTest
  6. from tests.support.mock import patch
  7. from tests.support.unit import TestCase
  8. class SaltAPITestCase(TestCase):
  9. @slowTest
  10. def test_start_shutdown(self):
  11. api = SaltAPI()
  12. try:
  13. # testing environment will fail if we use default pidfile
  14. # overwrite sys.argv so salt-api does not use testing args
  15. with patch.object(
  16. sys, "argv", [sys.argv[0], "--pid-file", "salt-api-test.pid"]
  17. ):
  18. api.start()
  19. self.assertTrue(os.path.isfile("salt-api-test.pid"))
  20. os.remove("salt-api-test.pid")
  21. finally:
  22. self.assertRaises(SystemExit, api.shutdown)