salt/tests/integration/states/host.py
Roman Imankulov bb0ed1a3a7 Tests cleanup
Defined "integration.run_tests()" function which can be used to execute
a particular integration test case. Existing bolerplate code in modules
and states tests is replaced with following lines:

    if __name__ == '__main__':
        from integration import run_tests
        run_tests(TestCaseName)

Typical usecase could look like this:

    python integration/modules/pip.py --no-clean -vv
2012-07-20 12:25:08 +06:00

46 lines
996 B
Python

'''
tests for host state
'''
# Import python libs
import os
import shutil
#
# Import salt libs
import integration
HFILE = os.path.join(integration.TMP, 'hosts')
class HostTest(integration.ModuleCase):
'''
Validate the host state
'''
def setUp(self):
shutil.copyfile(os.path.join(integration.FILES, 'hosts'), HFILE)
super(HostTest, self).setUp()
def tearDown(self):
if os.path.exists(HFILE):
os.remove(HFILE)
super(HostTest, self).tearDown()
def test_present(self):
'''
host.present
'''
name = 'spam.bacon'
ip = '10.10.10.10'
ret = self.run_state('host.present', name=name, ip=ip)
result = self.state_result(ret)
self.assertTrue(result)
with open(HFILE) as fp_:
output = fp_.read()
self.assertIn('{0}\t\t{1}'.format(ip, name), output)
if __name__ == '__main__':
from integration import run_tests
run_tests(HostTest)