2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2014-11-21 19:05:13 +00:00
|
|
|
# Import Python libs
|
2018-01-14 06:40:03 +00:00
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
2014-11-21 19:05:13 +00:00
|
|
|
|
2013-06-27 10:48:18 +00:00
|
|
|
# Import Salt Testing libs
|
2017-04-03 16:04:09 +00:00
|
|
|
from tests.support.case import ModuleCase
|
2012-05-14 05:51:22 +00:00
|
|
|
|
2012-05-29 16:40:20 +00:00
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
class AliasesTest(ModuleCase):
|
2012-05-14 05:51:22 +00:00
|
|
|
'''
|
|
|
|
Validate aliases module
|
|
|
|
'''
|
2014-05-15 18:47:26 +00:00
|
|
|
def test_set_target(self):
|
2012-05-14 05:51:22 +00:00
|
|
|
'''
|
|
|
|
aliases.set_target and aliases.get_target
|
|
|
|
'''
|
|
|
|
set_ret = self.run_function(
|
|
|
|
'aliases.set_target',
|
|
|
|
alias='fred',
|
|
|
|
target='bob')
|
|
|
|
self.assertTrue(set_ret)
|
|
|
|
tgt_ret = self.run_function(
|
|
|
|
'aliases.get_target',
|
|
|
|
alias='fred')
|
2014-05-15 18:47:26 +00:00
|
|
|
self.assertEqual(tgt_ret, 'bob')
|
2012-05-14 06:04:26 +00:00
|
|
|
|
2014-05-15 18:47:26 +00:00
|
|
|
def test_has_target(self):
|
2012-05-14 06:04:26 +00:00
|
|
|
'''
|
|
|
|
aliases.set_target and aliases.has_target
|
|
|
|
'''
|
|
|
|
set_ret = self.run_function(
|
|
|
|
'aliases.set_target',
|
|
|
|
alias='fred',
|
|
|
|
target='bob')
|
|
|
|
self.assertTrue(set_ret)
|
|
|
|
tgt_ret = self.run_function(
|
|
|
|
'aliases.has_target',
|
|
|
|
alias='fred',
|
|
|
|
target='bob')
|
|
|
|
self.assertTrue(tgt_ret)
|
2012-05-14 15:59:38 +00:00
|
|
|
|
2014-05-15 18:47:26 +00:00
|
|
|
def test_list_aliases(self):
|
2012-05-14 15:59:38 +00:00
|
|
|
'''
|
|
|
|
aliases.list_aliases
|
|
|
|
'''
|
|
|
|
set_ret = self.run_function(
|
|
|
|
'aliases.set_target',
|
|
|
|
alias='fred',
|
|
|
|
target='bob')
|
|
|
|
self.assertTrue(set_ret)
|
|
|
|
tgt_ret = self.run_function(
|
|
|
|
'aliases.list_aliases')
|
|
|
|
self.assertIsInstance(tgt_ret, dict)
|
2014-05-15 18:47:26 +00:00
|
|
|
self.assertIn('fred', tgt_ret)
|
2012-05-14 16:44:17 +00:00
|
|
|
|
|
|
|
def test_rm_alias(self):
|
|
|
|
'''
|
|
|
|
aliases.rm_alias
|
|
|
|
'''
|
|
|
|
set_ret = self.run_function(
|
|
|
|
'aliases.set_target',
|
|
|
|
alias='frank',
|
|
|
|
target='greg')
|
|
|
|
self.assertTrue(set_ret)
|
2014-05-15 18:47:26 +00:00
|
|
|
self.run_function(
|
|
|
|
'aliases.rm_alias',
|
|
|
|
alias='frank')
|
2012-05-14 16:44:17 +00:00
|
|
|
tgt_ret = self.run_function(
|
|
|
|
'aliases.list_aliases')
|
|
|
|
self.assertIsInstance(tgt_ret, dict)
|
|
|
|
self.assertNotIn('alias=frank', tgt_ret)
|