Merge pull request #24398 from makinacorpus/aptv

VirtualName for states.apt
This commit is contained in:
Colton Myers 2015-06-05 11:40:04 -06:00
commit c0ff4110ab
2 changed files with 13 additions and 7 deletions

View file

@ -14,11 +14,17 @@ import salt.utils
log = logging.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'apt'
def __virtual__():
'''
Only work on apt-based platforms with pkg.get_selections
'''
return 'pkg.get_selections' in __salt__
return (__virtualname__
if __salt__.get('pkg.get_selections', False)
else False)
def held(name):

View file

@ -18,16 +18,16 @@ from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import Salt Libs
from salt.states import apt
from salt.states import aptpkg
apt.__opts__ = {}
apt.__salt__ = {}
aptpkg.__opts__ = {}
aptpkg.__salt__ = {}
@skipIf(NO_MOCK, NO_MOCK_REASON)
class AptTestCase(TestCase):
'''
Test cases for salt.states.apt
Test cases for salt.states.aptpkg
'''
# 'held' function tests: 1
@ -43,8 +43,8 @@ class AptTestCase(TestCase):
'comment': 'Package {0} does not have a state'.format(name)}
mock = MagicMock(return_value=False)
with patch.dict(apt.__salt__, {'pkg.get_selections': mock}):
self.assertDictEqual(apt.held(name), ret)
with patch.dict(aptpkg.__salt__, {'pkg.get_selections': mock}):
self.assertDictEqual(aptpkg.held(name), ret)
if __name__ == '__main__':