salt/tests/integration/states/test_network.py

61 lines
1.9 KiB
Python
Raw Normal View History

2016-06-29 20:28:36 +00:00
# -*- encoding: utf-8 -*-
'''
:codeauthor: :email: `Justin Anderson <janderson@saltstack.com>`
tests.integration.states.network
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'''
# Python libs
from __future__ import absolute_import
# Import salt testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest
2017-04-02 16:09:47 +00:00
from tests.support.mixins import SaltReturnAssertsMixin
2016-06-29 20:28:36 +00:00
@destructiveTest
class NetworkTest(ModuleCase, SaltReturnAssertsMixin):
2016-06-29 20:28:36 +00:00
'''
Validate network state module
'''
def setUp(self):
os_family = self.run_function('grains.get', ['os_family'])
if os_family not in ('RedHat', 'Debian'):
self.skipTest('Network state only supported on RedHat and Debian based systems')
2016-06-29 20:28:36 +00:00
def test_managed(self):
'''
network.managed
'''
state_key = 'network_|-dummy0_|-dummy0_|-managed'
2016-07-11 20:35:25 +00:00
ret = self.run_function('state.sls', mods='network.managed', test=True)
self.assertEqual('Interface dummy0 is set to be added.', ret[state_key]['comment'])
2016-07-11 20:35:25 +00:00
2016-06-29 20:28:36 +00:00
def test_routes(self):
2016-07-11 20:35:25 +00:00
'''
2016-06-29 20:28:36 +00:00
network.routes
2016-07-11 20:35:25 +00:00
'''
2016-06-29 20:28:36 +00:00
state_key = 'network_|-routes_|-dummy0_|-routes'
expected_changes = 'Interface dummy0 routes are set to be added.'
2016-07-11 20:35:25 +00:00
ret = self.run_function('state.sls', mods='network.routes', test=True)
2016-07-11 20:35:25 +00:00
self.assertEqual(ret[state_key]['comment'], 'Interface dummy0 routes are set to be added.')
2016-07-11 20:35:25 +00:00
2016-06-29 20:28:36 +00:00
def test_system(self):
2016-07-11 20:35:25 +00:00
'''
2016-06-29 20:28:36 +00:00
network.system
2016-07-11 20:35:25 +00:00
'''
2016-06-29 20:28:36 +00:00
state_key = 'network_|-system_|-system_|-system'
2016-07-11 20:35:25 +00:00
global_settings = self.run_function('ip.get_network_settings')
ret = self.run_function('state.sls', mods='network.system', test=True)
self.assertIn(
'Global network settings are set to be {0}'.format(
'added' if not global_settings else 'updated'
),
ret[state_key]['comment']
)