mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix reg grains test
This commit is contained in:
parent
6d323aa8f0
commit
8a9027c0c9
1 changed files with 32 additions and 13 deletions
|
@ -8,9 +8,11 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
# Import Salt libs
|
||||
import salt.loader
|
||||
import salt.utils.platform
|
||||
if salt.utils.platform.is_windows():
|
||||
try:
|
||||
|
@ -27,19 +29,6 @@ class TestGrainsCore(ModuleCase):
|
|||
'''
|
||||
Test the core grains grains
|
||||
'''
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Only run on Windows')
|
||||
def test_win_cpu_model(self):
|
||||
'''
|
||||
test grains['cpu_model']
|
||||
'''
|
||||
cpu_model_text = salt.modules.reg.read_value(
|
||||
'HKEY_LOCAL_MACHINE',
|
||||
'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0',
|
||||
'ProcessorNameString').get('vdata')
|
||||
self.assertEqual(
|
||||
self.run_function('grains.items')['cpu_model'],
|
||||
cpu_model_text
|
||||
)
|
||||
|
||||
@skipIf(not _freebsd_or_openbsd(), 'Only run on FreeBSD or OpenBSD')
|
||||
def test_freebsd_openbsd_mem_total(self):
|
||||
|
@ -62,3 +51,33 @@ class TestGrainsCore(ModuleCase):
|
|||
self.run_function('grains.items')['swap_total'],
|
||||
int(swapmem) / 1048576
|
||||
)
|
||||
|
||||
|
||||
class TestGrainsReg(ModuleCase, LoaderModuleMockMixin):
|
||||
'''
|
||||
Test the core windows grains
|
||||
'''
|
||||
|
||||
def setup_loader_modules(self):
|
||||
self.opts = opts = salt.config.DEFAULT_MINION_OPTS
|
||||
utils = salt.loader.utils(opts, whitelist=['reg'])
|
||||
return {
|
||||
salt.modules.reg: {
|
||||
'__opts__': opts,
|
||||
'__utils__': utils,
|
||||
}
|
||||
}
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Only run on Windows')
|
||||
def test_win_cpu_model(self):
|
||||
'''
|
||||
test grains['cpu_model']
|
||||
'''
|
||||
cpu_model_text = salt.modules.reg.read_value(
|
||||
'HKEY_LOCAL_MACHINE',
|
||||
'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0',
|
||||
'ProcessorNameString').get('vdata')
|
||||
self.assertEqual(
|
||||
self.run_function('grains.items')['cpu_model'],
|
||||
cpu_model_text
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue