1 ##############################################################################
2 # Copyright (c) 2016 Dan Radez (Red Hat)
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # https://docs.python.org/3/library/io.html
14 from apex.deploy_settings import DeploySettings
15 from apex.deploy_settings import DeploySettingsException
17 from nose.tools import assert_equal
18 from nose.tools import assert_raises
19 from nose.tools import assert_is_instance
21 deploy_files = ('deploy_settings.yaml',
22 'os-nosdn-nofeature-noha.yaml',
23 'os-nosdn-ovs-noha.yaml',
24 'os-ocl-nofeature-ha.yaml',
25 'os-odl_l2-bgpvpn-ha.yaml',
26 'os-odl_l2-bgpvpn-noha.yaml',
27 'os-odl_l3-nofeature-ha.yaml',
28 'os-nosdn-nofeature-ha.yaml',
29 'os-nosdn-ovs-ha.yaml',
30 'os-nosdn-performance-ha.yaml',
31 'os-odl_l2-nofeature-ha.yaml',
32 'os-odl_l2-sfc-noha.yaml',
33 'os-onos-nofeature-ha.yaml',
34 'os-onos-sfc-ha.yaml')
36 test_deploy_content = (
38 'deploy_options: string',
39 """deploy_options: string
67 class TestIpUtils(object):
69 def setup_class(klass):
70 """This method is run once for each class before any tests are run"""
73 def teardown_class(klass):
74 """This method is run once for each class _after_ all tests are run"""
77 """This method is run once before _each_ test method is executed"""
80 """This method is run once after _each_ test method is executed"""
83 for f in deploy_files:
84 ds = DeploySettings('../config/deploy/{}'.format(f))
85 ds = DeploySettings(ds)
87 def test__validate_settings(self):
88 for c in test_deploy_content:
90 f = tempfile.NamedTemporaryFile(mode='w')
93 assert_raises(DeploySettingsException,
94 DeploySettings, f.name)
98 def test_dump_bash(self):
99 # the performance file has the most use of the function
100 # so using that as the test case
101 ds = DeploySettings('../config/deploy/os-nosdn-performance-ha.yaml')
102 assert_equal(ds.dump_bash(), None)
103 assert_equal(ds.dump_bash(path='/dev/null'), None)
105 def test_exception(sefl):
106 e = DeploySettingsException("test")
108 assert_is_instance(e, DeploySettingsException)