Merge pull request #13730 from pass-by-value/test_master_tops

Add regression test for master_tops
This commit is contained in:
Aditya Kulkarni 2014-06-25 17:19:54 -04:00
commit 3e423b4818
4 changed files with 57 additions and 0 deletions

View File

@ -33,3 +33,6 @@ external_auth:
- '@wheel'
- '@runner'
- test.*
master_tops:
master_tops_test: True

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
import logging
log = logging.getLogger(__name__)
def __virtual__():
log.info('master tops test loaded')
return 'master_tops_test'
def top(**kwargs):
log.info('master_tops_test')
return {'base': ['master_tops_test']}

View File

@ -71,7 +71,10 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
'''
src = os.path.join(integration.FILES, 'file/base/top.sls')
dst = os.path.join(integration.FILES, 'file/base/top.sls.bak')
src_mt = os.path.join(integration.FILES,'files/extension_modules/tops/master_tops_test.py')
dst_mt = os.path.join(integration.FILES, 'files/extension_modules/tops/master_tops_test.py.bak')
shutil.move(src, dst)
shutil.move(src_mt, dst_mt)
expected_comment = 'No Top file or external nodes data matches found'
try:
stdout, retcode = self.run_call(
@ -80,6 +83,7 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
)
finally:
shutil.move(dst, src)
shutil.move(dst_mt, src_mt)
self.assertIn(expected_comment, ''.join(stdout))
self.assertNotEqual(0, retcode)

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
'''
tests.integration.shell.master_tops
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'''
# Import python libs
import os
import yaml
import signal
import shutil
# Import Salt Testing libs
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import salt libs
import integration
class MasterTopsTest(integration.ShellCase):
_call_binary_ = 'salt'
def test_custom_tops_gets_utilized(self):
resp = self.run_call(
'state.show_top'
)
self.assertTrue(
any('master_tops_test' in _x for _x in resp)
)
if __name__ == '__main__':
from integration import run_tests
run_tests(MasterTopsTest)