2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2013-11-25 23:20:32 +00:00
|
|
|
'''
|
|
|
|
tests for pkgrepo states
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting import skipIf
|
|
|
|
from salttesting.helpers import (
|
|
|
|
destructiveTest,
|
|
|
|
ensure_in_syspath,
|
2013-11-28 19:26:21 +00:00
|
|
|
requires_system_grains
|
2013-11-25 23:20:32 +00:00
|
|
|
)
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
|
|
|
# Import salt libs
|
|
|
|
import integration
|
|
|
|
import salt.utils
|
|
|
|
|
|
|
|
|
|
|
|
class PkgrepoTest(integration.ModuleCase,
|
|
|
|
integration.SaltReturnAssertsMixIn):
|
|
|
|
'''
|
2013-11-25 23:30:18 +00:00
|
|
|
pkgrepo state tests
|
2013-11-25 23:20:32 +00:00
|
|
|
'''
|
|
|
|
@destructiveTest
|
|
|
|
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
2013-11-28 19:26:21 +00:00
|
|
|
@requires_system_grains
|
|
|
|
def test_pkgrepo_01_managed(self, grains):
|
2013-11-25 23:20:32 +00:00
|
|
|
'''
|
|
|
|
This is a destructive test as it adds a repository.
|
|
|
|
'''
|
2013-11-28 19:26:21 +00:00
|
|
|
if grains['os_family'] == 'Debian':
|
|
|
|
try:
|
|
|
|
from aptsources import sourceslist
|
|
|
|
except ImportError:
|
|
|
|
self.skipTest(
|
|
|
|
'aptsources.sourceslist python module not found'
|
|
|
|
)
|
2013-11-25 23:20:32 +00:00
|
|
|
ret = self.run_function('state.sls', mods='pkgrepo.managed')
|
2013-11-25 23:41:03 +00:00
|
|
|
# If the below assert fails then no states were run, and the SLS in
|
|
|
|
# tests/integration/files/file/base/pkgrepo/managed.sls needs to be
|
|
|
|
# corrected.
|
|
|
|
self.assertReturnNonEmptySaltType(ret)
|
2013-11-25 23:20:32 +00:00
|
|
|
for state_id, state_result in ret.iteritems():
|
|
|
|
self.assertSaltTrueReturn(dict([(state_id, state_result)]))
|
|
|
|
|
|
|
|
@destructiveTest
|
|
|
|
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
2013-11-25 23:30:18 +00:00
|
|
|
def test_pkgrepo_02_absent(self):
|
2013-11-25 23:20:32 +00:00
|
|
|
'''
|
|
|
|
This is a destructive test as it removes the repository added in the
|
|
|
|
above test.
|
|
|
|
'''
|
|
|
|
ret = self.run_function('state.sls', mods='pkgrepo.absent')
|
2013-11-25 23:41:03 +00:00
|
|
|
# If the below assert fails then no states were run, and the SLS in
|
|
|
|
# tests/integration/files/file/base/pkgrepo/absent.sls needs to be
|
|
|
|
# corrected.
|
|
|
|
self.assertReturnNonEmptySaltType(ret)
|
2013-11-25 23:20:32 +00:00
|
|
|
for state_id, state_result in ret.iteritems():
|
|
|
|
self.assertSaltTrueReturn(dict([(state_id, state_result)]))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
2013-11-25 23:27:26 +00:00
|
|
|
run_tests(PkgrepoTest)
|