salt/tests/integration/states/test_match.py

52 lines
1.4 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 tests.support.case import ModuleCase
from tests.support.paths import FILES
from tests.support.helpers import skip_if_not_root
# Import salt libs
import salt.utils
STATE_DIR = os.path.join(FILES, 'file', 'base')
2012-10-06 00:05:04 +00:00
class StateMatchTest(ModuleCase):
2012-10-06 00:05:04 +00:00
'''
Validate the file state
'''
@skip_if_not_root
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:
Clean up open filehandles (#35359) * salt/crypt.py: clean up open filehandles * salt/fileclient.py: clean up open filehandles * salt/grains/core.py: clean up open filehandles * salt/modules/cp.py: clean up open filehandles * salt/modules/data.py: clean up open filehandles * salt/modules/dnsutil.py: clean up open filehandles * salt/modules/dockerng.py: clean up open filehandles * salt/modules/inspectlib/collector.py: clean up open filehandles * salt/modules/file.py: clean up open filehandles * salt/modules/hosts.py: clean up open filehandles * salt/modules/incron.py: clean up open filehandles * salt/modules/dpkg.py: clean up open filehandles * salt/modules/linux_sysctl.py: clean up open filehandles * salt/modules/netbsd_sysctl.py: clean up open filehandles * salt/modules/network.py: clean up open filehandles * salt/modules/nftables.py: clean up open filehandles * salt/modules/openbsd_sysctl.py: clean up open filehandles * salt/modules/rh_ip.py: clean up open filehandles * salt/modules/portage_config.py: clean up open filehandles * salt/modules/status.py: clean up open filehandles * salt/modules/tls.py: clean up open filehandles * salt/modules/xapi.py: clean up open filehandles * salt/modules/x509.py: clean up open filehandles * salt/modules/virt.py: clean up open filehandles * salt/modules/zcbuildout.py: clean up open filehandles * salt/returners/local_cache.py: clean up open filehandles * salt/utils/cloud.py: clean up open filehandles * salt/states/pkgrepo.py: clean up open filehandles * salt/states/x509.py: clean up open filehandles * salt/transport/mixins/auth.py: clean up open filehandles * salt/utils/__init__.py: clean up open filehandles * salt/states/pkg.py: clean up open filehandles * salt/utils/minion.py: clean up open filehandles * salt/utils/openstack/nova.py: clean up open filehandles * salt/utils/openstack/swift.py: clean up open filehandles * salt/utils/process.py: clean up open filehandles * salt/utils/templates.py: clean up open filehandles * salt/utils/virt.py: clean up open filehandles * tests/integration/__init__.py: clean up open filehandles * tests/integration/cli/grains.py: clean up open filehandles * tests/integration/client/standard.py: clean up open filehandles * tests/integration/modules/hosts.py: clean up open filehandles * tests/unit/utils/vt_test.py: clean up open filehandles * tests/integration/shell/enabled.py: clean up open filehandles * tests/integration/states/cmd.py: clean up open filehandles * tests/integration/states/file.py: clean up open filehandles * tests/integration/states/match.py: clean up open filehandles * tests/unit/config_test.py: clean up open filehandles * tests/unit/templates/jinja_test.py: clean up open filehandles * tests/unit/utils/find_test.py: clean up open filehandles * tests/integration/modules/state.py: clean up open filehandles * Update dnsutil_test to reflect changes in fopen usage
2016-08-11 16:45:24 +00:00
with salt.utils.fopen(top_file, 'w') as fp_:
fp_.write(
'base:\n'
' {0}:\n'
' - match: ipcidr\n'
' - test\n'.format(subnets[0])
)
2012-10-06 00:05:04 +00:00
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)