2016-03-19 08:05:15 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
Integration tests for the alternatives state module
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Import Python libs
|
|
|
|
from __future__ import absolute_import
|
2016-03-24 22:12:01 +00:00
|
|
|
import os
|
2016-03-19 08:05:15 +00:00
|
|
|
|
|
|
|
# Import Salt Testing libs
|
2017-02-27 15:59:04 +00:00
|
|
|
import tests.integration as integration
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import skipIf
|
2017-02-27 15:59:04 +00:00
|
|
|
from tests.support.helpers import destructiveTest
|
2016-03-19 08:05:15 +00:00
|
|
|
|
2016-03-24 22:12:01 +00:00
|
|
|
NO_ALTERNATIVES = False
|
2016-03-24 22:33:18 +00:00
|
|
|
if not os.path.exists('/etc/alternatives'):
|
2016-03-24 22:12:01 +00:00
|
|
|
NO_ALTERNATIVES = True
|
2016-03-19 08:05:15 +00:00
|
|
|
|
2016-03-24 22:12:01 +00:00
|
|
|
|
|
|
|
@skipIf(NO_ALTERNATIVES, '/etc/alternatives does not exist on the system')
|
2016-03-19 08:05:15 +00:00
|
|
|
class AlterantivesStateTest(integration.ModuleCase,
|
2017-04-02 15:21:06 +00:00
|
|
|
integration.SaltReturnAssertsMixin):
|
2016-03-19 08:05:15 +00:00
|
|
|
@destructiveTest
|
|
|
|
def test_install_set_and_remove(self):
|
|
|
|
ret = self.run_state('alternatives.set', name='alt-test', path='/bin/true')
|
|
|
|
self.assertSaltFalseReturn(ret)
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.install', name='alt-test',
|
|
|
|
link='/usr/local/bin/alt-test', path='/bin/true', priority=50)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertSaltStateChangesEqual(ret, '/bin/true', keys=['path'])
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.install', name='alt-test',
|
|
|
|
link='/usr/local/bin/alt-test', path='/bin/true', priority=50)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertSaltStateChangesEqual(ret, {})
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.install', name='alt-test',
|
|
|
|
link='/usr/local/bin/alt-test', path='/bin/false', priority=90)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertSaltStateChangesEqual(ret, '/bin/false', keys=['path'])
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.set', name='alt-test', path='/bin/false')
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertSaltStateChangesEqual(ret, {})
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.set', name='alt-test', path='/bin/true')
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertSaltStateChangesEqual(ret, '/bin/true', keys=['path'])
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.set', name='alt-test', path='/bin/true')
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertSaltStateChangesEqual(ret, {})
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.remove', name='alt-test', path='/bin/true')
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
ret = self.run_state('alternatives.remove', name='alt-test', path='/bin/false')
|
|
|
|
self.assertSaltTrueReturn(ret)
|