mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
74d315fd28
Conflicts: - salt/modules/file.py - tests/unit/modules/test_file.py
78 lines
1.9 KiB
Python
78 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
'''
|
|
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
|
|
:copyright: Copyright 2017 by the SaltStack Team, see AUTHORS for more details.
|
|
|
|
|
|
tests.unit.beacons.test_status
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Status beacon test cases
|
|
'''
|
|
|
|
# Python libs
|
|
from __future__ import absolute_import
|
|
import sys
|
|
|
|
# Salt libs
|
|
import salt.config
|
|
import salt.loader
|
|
from salt.beacons import status
|
|
import salt.modules.status as status_module
|
|
|
|
# Salt testing libs
|
|
from tests.support.unit import TestCase
|
|
from tests.support.mixins import LoaderModuleMockMixin
|
|
|
|
|
|
class StatusBeaconTestCase(TestCase, LoaderModuleMockMixin):
|
|
'''
|
|
Test case for salt.beacons.status
|
|
'''
|
|
|
|
def setup_loader_modules(self):
|
|
opts = salt.config.DEFAULT_MINION_OPTS
|
|
module_globals = {
|
|
'__opts__': opts,
|
|
'__salt__': 'autoload',
|
|
'__context__': {},
|
|
'__grains__': {'kernel': 'Linux'}
|
|
}
|
|
return {
|
|
status: module_globals,
|
|
status_module: module_globals
|
|
}
|
|
|
|
def test_empty_config(self, *args, **kwargs):
|
|
config = {}
|
|
ret = status.beacon(config)
|
|
|
|
if sys.platform.startswith('win'):
|
|
expected = []
|
|
else:
|
|
expected = sorted(['loadavg', 'meminfo', 'cpustats', 'vmstats', 'time'])
|
|
|
|
self.assertEqual(sorted(list(ret[0]['data'])), expected)
|
|
|
|
def test_deprecated_dict_config(self):
|
|
config = {'time': ['all']}
|
|
ret = status.beacon(config)
|
|
|
|
if sys.platform.startswith('win'):
|
|
expected = []
|
|
else:
|
|
expected = ['time']
|
|
|
|
self.assertEqual(list(ret[0]['data']), expected)
|
|
|
|
def test_list_config(self):
|
|
config = [{'time': ['all']}]
|
|
ret = status.beacon(config)
|
|
|
|
if sys.platform.startswith('win'):
|
|
expected = []
|
|
else:
|
|
expected = ['time']
|
|
|
|
self.assertEqual(list(ret[0]['data']), expected)
|