diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000..5fcccac --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./unit_tests +top_dir=./ diff --git a/src/lib/charm/openstack/neutron_arista.py b/src/lib/charm/openstack/neutron_arista.py index fa3f730..ad8bed3 100644 --- a/src/lib/charm/openstack/neutron_arista.py +++ b/src/lib/charm/openstack/neutron_arista.py @@ -1,24 +1,14 @@ #!/usr/bin/env python -import subprocess - from collections import OrderedDict - -import charmhelpers.core.hookenv as hookenv -from charmhelpers.core.hookenv import ( - config, - log, - status_set, -) +from charmhelpers.core.hookenv import config import charms_openstack.charm from charmhelpers.contrib.openstack import ( context, templating, ) -from charmhelpers.contrib.openstack.utils import ( - CompareOpenStackReleases, - os_release, -) +from charmhelpers.contrib.openstack.utils import os_release + ML2_CONFIG = '/etc/neutron/plugins/ml2/ml2_conf_arista.ini' TEMPLATES = 'templates/' @@ -53,6 +43,7 @@ class NeutronAristaCharm(charms_openstack.charm.OpenStackCharm): configs.register(cfg, rscs['contexts']) return configs + class AristaMl2Context(context.OSContextGenerator): def __call__(self): diff --git a/src/reactive/neutron_arista_handlers.py b/src/reactive/neutron_arista_handlers.py index d10adc6..60fec6f 100644 --- a/src/reactive/neutron_arista_handlers.py +++ b/src/reactive/neutron_arista_handlers.py @@ -22,7 +22,6 @@ from charms_openstack.charm import ( use_defaults, ) import charm.openstack.neutron_arista as arista # noqa -from charm.openstack.neutron_arista import register_configs use_defaults('update-status') diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..733add4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,48 @@ +[tox] +skipsdist = True +envlist = pep8,py3 + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 + TERM=linux + LAYER_PATH={toxinidir}/layers + JUJU_REPOSITORY={toxinidir}/build +passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH +install_command = + pip install {opts} {packages} +deps = + -r{toxinidir}/requirements.txt + +[testenv:build] +basepython = python3 +commands = + charm-build --log-level DEBUG -o {toxinidir}/build src {posargs} + +[testenv:py3] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run {posargs} + +[testenv:py35] +basepython = python3.5 +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run {posargs} + +[testenv:py36] +basepython = python3.6 +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run {posargs} + +[testenv:pep8] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt +commands = flake8 {posargs} src unit_tests + +[testenv:venv] +basepython = python3 +commands = {posargs} + +[flake8] +# E402 ignore necessary for path append before sys module import in actions +ignore = E402 diff --git a/unit_tests/test_lib_charm_openstack_neutron_arista.py b/unit_tests/test_lib_charm_openstack_neutron_arista.py index c2adc13..eec24eb 100644 --- a/unit_tests/test_lib_charm_openstack_neutron_arista.py +++ b/unit_tests/test_lib_charm_openstack_neutron_arista.py @@ -15,13 +15,10 @@ from __future__ import absolute_import from __future__ import print_function -import contextlib import unittest import mock -import charm.openstack.neutron_arista as neutron_arista - def FakeConfig(init_dict): diff --git a/unit_tests/test_neutron_arista_handlers.py b/unit_tests/test_neutron_arista_handlers.py index c72ca00..e1ce33c 100644 --- a/unit_tests/test_neutron_arista_handlers.py +++ b/unit_tests/test_neutron_arista_handlers.py @@ -1,6 +1,6 @@ import mock -import reactive.designate_handlers as handlers +import reactive.neutron_arista_handlers as handlers import charms_openstack.test_utils as test_utils @@ -11,13 +11,11 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks): # test that the hooks actually registered the relation expressions that # are meaningful for this interface: this is to handle regressions. # The keys are the function names that the hook attaches to. - all_interfaces = ( - 'neutron-plugin-api-subordinate.connected', ) hook_set = { 'when': { 'configure_principle': ( 'neutron-plugin-api-subordinate.connected', ), - } + } } # test that the hooks were registered via the # reactive.barbican_handlers @@ -37,5 +35,6 @@ class TestHandlers(test_utils.PatchHelper): def test_configure_principal(self): the_charm = self._patch_provide_charm_instance() - handlers.configure_principle('neutron-api') + principal_charm = mock.MagicMock() + handlers.configure_principle(principal_charm) the_charm.write_config.assert_called_once_with()