mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
bb0ed1a3a7
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
46 lines
996 B
Python
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)
|