1
0

test_aliases.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. from tests.support.helpers import slowTest
  6. @pytest.mark.windows_whitelisted
  7. class AliasesTest(ModuleCase):
  8. """
  9. Validate aliases module
  10. """
  11. @slowTest
  12. def test_set_target(self):
  13. """
  14. aliases.set_target and aliases.get_target
  15. """
  16. set_ret = self.run_function("aliases.set_target", alias="fred", target="bob")
  17. self.assertTrue(set_ret)
  18. tgt_ret = self.run_function("aliases.get_target", alias="fred")
  19. self.assertEqual(tgt_ret, "bob")
  20. @slowTest
  21. def test_has_target(self):
  22. """
  23. aliases.set_target and aliases.has_target
  24. """
  25. set_ret = self.run_function("aliases.set_target", alias="fred", target="bob")
  26. self.assertTrue(set_ret)
  27. tgt_ret = self.run_function("aliases.has_target", alias="fred", target="bob")
  28. self.assertTrue(tgt_ret)
  29. @slowTest
  30. def test_list_aliases(self):
  31. """
  32. aliases.list_aliases
  33. """
  34. set_ret = self.run_function("aliases.set_target", alias="fred", target="bob")
  35. self.assertTrue(set_ret)
  36. tgt_ret = self.run_function("aliases.list_aliases")
  37. self.assertIsInstance(tgt_ret, dict)
  38. self.assertIn("fred", tgt_ret)
  39. @slowTest
  40. def test_rm_alias(self):
  41. """
  42. aliases.rm_alias
  43. """
  44. set_ret = self.run_function("aliases.set_target", alias="frank", target="greg")
  45. self.assertTrue(set_ret)
  46. self.run_function("aliases.rm_alias", alias="frank")
  47. tgt_ret = self.run_function("aliases.list_aliases")
  48. self.assertIsInstance(tgt_ret, dict)
  49. self.assertNotIn("alias=frank", tgt_ret)