summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2016-06-20 05:56:34 -0400
committerDan Radez <dradez@redhat.com>2016-06-30 18:18:00 -0400
commit45fabbab6a4107df8a32f09045cf955afeb2e4ac (patch)
tree15b49db13ffb5b17ff69ef84ed298531184c3072 /tests
parent0b91edabf51d60968a20d605dd2b97f03283e06b (diff)
Syntax updates and new tests
- syntax updates to match pep8 standards - tests to cover apex_python_utils.py Change-Id: Ifac06fdbb97266f1b574b20610979b6965d6dd55 Signed-off-by: Dan Radez <dradez@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_apex_deploy_env.py17
-rw-r--r--tests/test_apex_ip_utils.py9
-rw-r--r--tests/test_apex_network_environment.py3
-rw-r--r--tests/test_apex_python_utils_py.py80
4 files changed, 95 insertions, 14 deletions
diff --git a/tests/test_apex_deploy_env.py b/tests/test_apex_deploy_env.py
index 0cd144ef..648923d0 100644
--- a/tests/test_apex_deploy_env.py
+++ b/tests/test_apex_deploy_env.py
@@ -30,23 +30,23 @@ deploy_files = ('deploy_settings.yaml',
'os-onos-nofeature-ha.yaml')
test_deploy_content = (
-'global_params:',
-'deploy_options: string',
-"""deploy_options: string
+ 'global_params:',
+ 'deploy_options: string',
+ """deploy_options: string
global_params:""",
-"""global_params:
+ """global_params:
deploy_options:
error: error
""",
-"""global_params:
+ """global_params:
deploy_options:
performance: string
""",
-"""global_params:
+ """global_params:
deploy_options:
dataplane: invalid
""",
-"""global_params:
+ """global_params:
deploy_options:
performance:
Controller:
@@ -78,7 +78,8 @@ class TestIpUtils(object):
f = open('/tmp/apex_deploy_test_file', 'w')
f.write(c)
f.close()
- assert_raises(DeploySettingsException, DeploySettings, '/tmp/apex_deploy_test_file')
+ assert_raises(DeploySettingsException,
+ DeploySettings, '/tmp/apex_deploy_test_file')
def test_dump_bash(self):
# the performance file has the most use of the function
diff --git a/tests/test_apex_ip_utils.py b/tests/test_apex_ip_utils.py
index dc3aadf7..60c8b2b8 100644
--- a/tests/test_apex_ip_utils.py
+++ b/tests/test_apex_ip_utils.py
@@ -60,9 +60,9 @@ class TestIpUtils(object):
def test_get_interface(self):
assert_equal(get_interface(''), None)
assert_equal(get_interface('notreal'), None)
- assert_is_instance(get_interface(
- self.iface_name,
- address_family=4), IPv4Address)
+ assert_is_instance(get_interface(self.iface_name,
+ address_family=4),
+ IPv4Address)
# assert_is_instance(get_interface(
# self.iface_name,
# address_family=6), IPv6Address)
@@ -93,8 +93,7 @@ class TestIpUtils(object):
assert_regexp_matches(get_ip_range(interface=self.iface, end_offset=20,
count=10), ip4_range_pattern)
- @staticmethod
- def test_get_ip_range_with_cidr():
+ def test_get_ip_range_with_cidr(self):
cidr = ip_network('10.10.10.0/24')
assert_raises(IPUtilsException, get_ip_range, cidr=cidr)
assert_regexp_matches(get_ip_range(cidr=cidr, start_offset=1,
diff --git a/tests/test_apex_network_environment.py b/tests/test_apex_network_environment.py
index 90c89073..2a8438fa 100644
--- a/tests/test_apex_network_environment.py
+++ b/tests/test_apex_network_environment.py
@@ -33,7 +33,8 @@ class TestNetworkEnvironment(object):
"""This method is run once after _each_ test method is executed"""
def test_init(self):
- assert_raises(NetworkEnvException, NetworkEnvironment, None, '../build/network-environment.yaml')
+ assert_raises(NetworkEnvException, NetworkEnvironment,
+ None, '../build/network-environment.yaml')
def test_get_netenv_settings(self):
ns = NetworkSettings('../config/network/network_settings.yaml', True)
diff --git a/tests/test_apex_python_utils_py.py b/tests/test_apex_python_utils_py.py
new file mode 100644
index 00000000..47c10092
--- /dev/null
+++ b/tests/test_apex_python_utils_py.py
@@ -0,0 +1,80 @@
+##############################################################################
+# 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 sys
+
+from test_apex_ip_utils import get_default_gateway_linux
+from apex_python_utils import main
+from apex_python_utils import get_parser
+from apex_python_utils import parse_net_settings
+from apex_python_utils import parse_deploy_settings
+from apex_python_utils import find_ip
+from apex_python_utils import build_nic_template
+
+from nose.tools import assert_equal
+from nose.tools import assert_raises
+
+
+net_sets = '../config/network/network_settings.yaml'
+net_env = '../build/network-environment.yaml'
+deploy_sets = '../config/deploy/deploy_settings.yaml'
+nic_template = '../build/nics-template.yaml.jinja2'
+
+
+class TestCommonUtils(object):
+ @classmethod
+ def setup_class(klass):
+ """This method is run once for each class before any tests are run"""
+ klass.parser = get_parser()
+ klass.iface_name = get_default_gateway_linux()
+
+ @classmethod
+ def teardown_class(klass):
+ """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_main(self):
+ sys.argv = ['apex_python_utils', '-l', '/dev/null']
+ assert_raises(SystemExit, main)
+ sys.argv = ['apex_python_utils', '--debug', '-l', '/dev/null']
+ assert_raises(SystemExit, main)
+ sys.argv = ['apex_python_utils', '-l', '/dev/null',
+ 'parse-deploy-settings',
+ '-f', deploy_sets]
+ assert_equal(main(), None)
+
+ def test_parse_net_settings(self):
+ args = self.parser.parse_args(['parse-net-settings',
+ '-s', net_sets,
+ '-i', 'True',
+ '-e', net_env])
+ assert_equal(parse_net_settings(args), None)
+
+ def test_parse_deploy_settings(self):
+ args = self.parser.parse_args(['parse-deploy-settings',
+ '-f', deploy_sets])
+ assert_equal(parse_deploy_settings(args), None)
+
+ def test_find_ip(self):
+ args = self.parser.parse_args(['find-ip',
+ '-i', self.iface_name])
+ assert_equal(find_ip(args), None)
+
+ def test_build_nic_template(self):
+ args = self.parser.parse_args(['nic-template',
+ '-s', net_sets,
+ '-r', 'compute',
+ '-t', nic_template,
+ '-n', 'admin_network'])
+ assert_equal(build_nic_template(args), None)