salt/tests/integration/states/match.py

57 lines
1.5 KiB
Python
Raw Normal View History

2012-10-06 00:05:04 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
tests.integration.states.match
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'''
2012-10-06 00:05:04 +00:00
# Import python libs
from __future__ import absolute_import
2012-10-06 00:05:04 +00:00
import os
# Import Salt Testing libs
from salttesting import skipIf
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import salt libs
import integration
import salt.utils
2012-10-06 00:05:04 +00:00
STATE_DIR = os.path.join(integration.FILES, 'file', 'base')
2012-10-06 00:05:04 +00:00
class StateMatchTest(integration.ModuleCase):
'''
Validate the file state
'''
2013-04-30 17:32:21 +00:00
@skipIf(os.geteuid() != 0, 'you must be root to run this test')
2012-10-06 00:05:04 +00:00
def test_issue_2167_ipcidr_no_AttributeError(self):
subnets = self.run_function('network.subnets')
self.assertTrue(len(subnets) > 0)
2012-10-06 00:05:04 +00:00
top_filename = 'issue-2167-ipcidr-match.sls'
top_file = os.path.join(STATE_DIR, top_filename)
try:
salt.utils.fopen(top_file, 'w').write(
2012-10-06 00:05:04 +00:00
'base:\n'
' {0}:\n'
' - match: ipcidr\n'
' - test\n'.format(subnets[0])
)
ret = self.run_function('state.top', [top_filename])
self.assertNotIn(
'AttributeError: \'Matcher\' object has no attribute '
'\'functions\'',
2012-10-06 00:05:04 +00:00
ret
)
finally:
os.remove(top_file)
if __name__ == '__main__':
from integration import run_tests
run_tests(StateMatchTest)