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 ##############################################################################
12 from apex.tests import constants as con
13 from apex.common import parsers as apex_parsers
14 from apex.common.exceptions import ApexDeployException
15 from nose.tools import (
22 class TestCommonParsers:
25 """This method is run once for each class before any tests are run"""
28 def teardown_class(cls):
29 """This method is run once for each class _after_ all tests are run"""
32 """This method is run once before _each_ test method is executed"""
35 """This method is run once after _each_ test method is executed"""
37 def test_parse_nova_output(self):
38 output = apex_parsers.parse_nova_output(
39 os.path.join(con.TEST_DUMMY_CONFIG, 'nova_output.json'))
40 assert_is_instance(output, dict)
42 'overcloud-controller-0': '192.30.9.8',
43 'overcloud-novacompute-0': '192.30.9.10',
44 'overcloud-novacompute-1': '192.30.9.9'
46 assert_dict_equal(output, nodes)
48 def test_negative_parse_nova_output(self):
49 assert_raises(ApexDeployException, apex_parsers.parse_nova_output,
50 os.path.join(con.TEST_DUMMY_CONFIG,
51 'bad_nova_output.json'))
53 def test_parse_overcloudrc(self):
54 output = apex_parsers.parse_overcloudrc(
55 os.path.join(con.TEST_DUMMY_CONFIG, 'test_overcloudrc'))
56 assert_is_instance(output, dict)
57 assert 'OS_AUTH_TYPE' in output.keys()
58 assert output['OS_AUTH_TYPE'] == 'password'
59 assert 'OS_PASSWORD' in output.keys()
60 assert output['OS_PASSWORD'] == 'Wd8ruyf6qG8cmcms6dq2HM93f'
62 def test_parse_ifcfg(self):
63 output = apex_parsers.parse_ifcfg_file(
64 os.path.join(con.TEST_DUMMY_CONFIG, 'ifcfg-br-external'))
65 assert_is_instance(output, dict)
66 assert 'IPADDR' in output.keys()
67 assert output['IPADDR'] == '172.30.9.66'
68 assert 'NETMASK' in output.keys()
69 assert output['NETMASK'] == '255.255.255.0'
70 assert 'DNS1' in output.keys()
71 assert not output['DNS1']