mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
'''
|
|
tests for host state
|
|
'''
|
|
|
|
# Import python libs
|
|
from __future__ import absolute_import
|
|
import os
|
|
import shutil
|
|
|
|
# Import Salt Testing libs
|
|
from salttesting.helpers import ensure_in_syspath
|
|
ensure_in_syspath('../../')
|
|
|
|
# Import salt libs
|
|
import integration
|
|
import salt.utils
|
|
|
|
HFILE = os.path.join(integration.TMP, 'hosts')
|
|
|
|
|
|
class HostTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
|
'''
|
|
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)
|
|
self.assertSaltTrueReturn(ret)
|
|
with salt.utils.fopen(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)
|