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_dpdk-noha.yaml',
24 'os-ocl-nofeature-ha.yaml',
25 'os-odl-bgpvpn-ha.yaml',
26 'os-odl-bgpvpn-noha.yaml',
27 'os-odl-nofeature-ha.yaml',
28 'os-nosdn-nofeature-ha.yaml',
29 'os-nosdn-ovs_dpdk-ha.yaml',
30 'os-nosdn-performance-ha.yaml',
31 'os-odl-nofeature-ha.yaml',
32 'os-onos-nofeature-ha.yaml',
33 'os-onos-sfc-ha.yaml')
35 test_deploy_content = (
37 'deploy_options: string',
38 """deploy_options: string
66 class TestIpUtils(object):
68 def setup_class(klass):
69 """This method is run once for each class before any tests are run"""
72 def teardown_class(klass):
73 """This method is run once for each class _after_ all tests are run"""
76 """This method is run once before _each_ test method is executed"""
79 """This method is run once after _each_ test method is executed"""
82 for f in deploy_files:
83 ds = DeploySettings('../config/deploy/{}'.format(f))
84 ds = DeploySettings(ds)
86 def test__validate_settings(self):
87 for c in test_deploy_content:
89 f = tempfile.NamedTemporaryFile(mode='w')
92 assert_raises(DeploySettingsException,
93 DeploySettings, f.name)
97 def test_dump_bash(self):
98 # the performance file has the most use of the function
99 # so using that as the test case
100 ds = DeploySettings('../config/deploy/os-nosdn-performance-ha.yaml')
101 assert_equal(ds.dump_bash(), None)
102 assert_equal(ds.dump_bash(path='/dev/null'), None)
104 def test_exception(sefl):
105 e = DeploySettingsException("test")
107 assert_is_instance(e, DeploySettingsException)