mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
VirtualName for states.apt
This fixes #24397 Signed-off-by: Mathieu Le Marec - Pasquet <kiorky@cryptelium.net>
This commit is contained in:
parent
3ca35d1ec3
commit
785d27707f
@ -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):
|
@ -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__':
|
||||
|
Loading…
Reference in New Issue
Block a user