summaryrefslogtreecommitdiffstats
path: root/apex/tests/test_apex_common_parsers.py
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2017-09-06 14:33:18 -0400
committerTim Rozet <trozet@redhat.com>2017-09-06 19:02:27 +0000
commitf443d4ea68736bfb7849f83ed054fcbd51971765 (patch)
treeec73ab09401bbcb18ed0681835d8a10f9f3dadea /apex/tests/test_apex_common_parsers.py
parent27018324387d4ef0efa908b315403a636f92de55 (diff)
Adds parser tests and cleanup
Adds unit testing for the common/parsers library and cleans up some of the test files syntax. Change-Id: I7ff9d7ba20b028fba410af900a0c3107a5806d8f Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'apex/tests/test_apex_common_parsers.py')
-rw-r--r--apex/tests/test_apex_common_parsers.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/apex/tests/test_apex_common_parsers.py b/apex/tests/test_apex_common_parsers.py
new file mode 100644
index 00000000..bed2a8c5
--- /dev/null
+++ b/apex/tests/test_apex_common_parsers.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2016 Dan Radez (Red Hat)
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import os
+
+from apex.tests import constants as con
+from apex.common import parsers as apex_parsers
+from nose.tools import (
+ assert_is_instance,
+ assert_dict_equal
+)
+
+
+class TestCommonParsers:
+ @classmethod
+ def setup_class(cls):
+ """This method is run once for each class before any tests are run"""
+
+ @classmethod
+ def teardown_class(cls):
+ """This method is run once for each class _after_ all tests are run"""
+
+ def setup(self):
+ """This method is run once before _each_ test method is executed"""
+
+ def teardown(self):
+ """This method is run once after _each_ test method is executed"""
+
+ def test_parse_nova_output(self):
+ output = apex_parsers.parse_nova_output(
+ os.path.join(con.TEST_DUMMY_CONFIG, 'nova_output.json'))
+ assert_is_instance(output, dict)
+ nodes = {
+ 'overcloud-controller-0': '192.30.9.8',
+ 'overcloud-novacompute-0': '192.30.9.10',
+ 'overcloud-novacompute-1': '192.30.9.9'
+ }
+ print(output)
+ assert_dict_equal(output, nodes)
+
+ def test_parse_overcloudrc(self):
+ output = apex_parsers.parse_overcloudrc(
+ os.path.join(con.TEST_DUMMY_CONFIG, 'test_overcloudrc'))
+ assert_is_instance(output, dict)
+ assert 'OS_AUTH_TYPE' in output.keys()
+ assert output['OS_AUTH_TYPE'] == 'password'
+ assert 'OS_PASSWORD' in output.keys()
+ assert output['OS_PASSWORD'] == 'Wd8ruyf6qG8cmcms6dq2HM93f'