test_aliases.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import, print_function, unicode_literals
  3. import pytest
  4. from tests.support.case import ModuleCase
  5. @pytest.mark.windows_whitelisted
  6. class AliasesTest(ModuleCase):
  7. """
  8. Validate aliases module
  9. """
  10. @pytest.mark.slow_test(seconds=30) # Test takes >10 and <=30 seconds
  11. def test_set_target(self):
  12. """
  13. aliases.set_target and aliases.get_target
  14. """
  15. set_ret = self.run_function("aliases.set_target", alias="fred", target="bob")
  16. self.assertTrue(set_ret)
  17. tgt_ret = self.run_function("aliases.get_target", alias="fred")
  18. self.assertEqual(tgt_ret, "bob")
  19. @pytest.mark.slow_test(seconds=30) # Test takes >10 and <=30 seconds
  20. def test_has_target(self):
  21. """
  22. aliases.set_target and aliases.has_target
  23. """
  24. set_ret = self.run_function("aliases.set_target", alias="fred", target="bob")
  25. self.assertTrue(set_ret)
  26. tgt_ret = self.run_function("aliases.has_target", alias="fred", target="bob")
  27. self.assertTrue(tgt_ret)
  28. @pytest.mark.slow_test(seconds=30) # Test takes >10 and <=30 seconds
  29. def test_list_aliases(self):
  30. """
  31. aliases.list_aliases
  32. """
  33. set_ret = self.run_function("aliases.set_target", alias="fred", target="bob")
  34. self.assertTrue(set_ret)
  35. tgt_ret = self.run_function("aliases.list_aliases")
  36. self.assertIsInstance(tgt_ret, dict)
  37. self.assertIn("fred", tgt_ret)
  38. @pytest.mark.slow_test(seconds=60) # Test takes >30 and <=60 seconds
  39. def test_rm_alias(self):
  40. """
  41. aliases.rm_alias
  42. """
  43. set_ret = self.run_function("aliases.set_target", alias="frank", target="greg")
  44. self.assertTrue(set_ret)
  45. self.run_function("aliases.rm_alias", alias="frank")
  46. tgt_ret = self.run_function("aliases.list_aliases")
  47. self.assertIsInstance(tgt_ret, dict)
  48. self.assertNotIn("alias=frank", tgt_ret)