2017-03-09 19:28:13 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
|
|
|
|
: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
|
|
|
|
|
|
|
|
# Salt libs
|
|
|
|
import salt.config
|
|
|
|
import salt.loader
|
|
|
|
from salt.beacons import status
|
2017-03-21 17:15:36 +00:00
|
|
|
import salt.modules.status as status_module
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
'''
|
|
|
|
|
2017-03-22 12:12:36 +00:00
|
|
|
def setup_loader_modules(self):
|
2017-03-09 19:28:13 +00:00
|
|
|
opts = salt.config.DEFAULT_MINION_OPTS
|
2017-03-22 12:12:36 +00:00
|
|
|
module_globals = {
|
2017-03-09 19:28:13 +00:00
|
|
|
'__opts__': opts,
|
|
|
|
'__salt__': 'autoload',
|
|
|
|
'__context__': {},
|
|
|
|
'__grains__': {'kernel': 'Linux'}
|
|
|
|
}
|
2017-03-22 12:12:36 +00:00
|
|
|
return {
|
|
|
|
status: module_globals,
|
|
|
|
status_module: module_globals
|
|
|
|
}
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
def test_empty_config(self, *args, **kwargs):
|
|
|
|
config = {}
|
|
|
|
ret = status.beacon(config)
|
2017-03-13 18:02:33 +00:00
|
|
|
self.assertEqual(sorted(list(ret[0]['data'])), sorted(['loadavg', 'meminfo', 'cpustats', 'vmstats', 'time']))
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
def test_deprecated_dict_config(self):
|
|
|
|
config = {'time': ['all']}
|
|
|
|
ret = status.beacon(config)
|
2017-03-13 18:02:33 +00:00
|
|
|
self.assertEqual(list(ret[0]['data']), ['time'])
|
2017-03-09 19:28:13 +00:00
|
|
|
|
|
|
|
def test_list_config(self):
|
|
|
|
config = [{'time': ['all']}]
|
|
|
|
ret = status.beacon(config)
|
2017-03-13 18:02:33 +00:00
|
|
|
self.assertEqual(list(ret[0]['data']), ['time'])
|