fix unit testing
This commit is contained in:
parent
5ea25bbcbd
commit
8e3a5cc0cc
|
@ -0,0 +1,3 @@
|
||||||
|
[DEFAULT]
|
||||||
|
test_path=./unit_tests
|
||||||
|
top_dir=./
|
|
@ -1,24 +1,14 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from charmhelpers.core.hookenv import config
|
||||||
import charmhelpers.core.hookenv as hookenv
|
|
||||||
from charmhelpers.core.hookenv import (
|
|
||||||
config,
|
|
||||||
log,
|
|
||||||
status_set,
|
|
||||||
)
|
|
||||||
import charms_openstack.charm
|
import charms_openstack.charm
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack import (
|
from charmhelpers.contrib.openstack import (
|
||||||
context,
|
context,
|
||||||
templating,
|
templating,
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import os_release
|
||||||
CompareOpenStackReleases,
|
|
||||||
os_release,
|
|
||||||
)
|
|
||||||
|
|
||||||
ML2_CONFIG = '/etc/neutron/plugins/ml2/ml2_conf_arista.ini'
|
ML2_CONFIG = '/etc/neutron/plugins/ml2/ml2_conf_arista.ini'
|
||||||
TEMPLATES = 'templates/'
|
TEMPLATES = 'templates/'
|
||||||
|
@ -53,6 +43,7 @@ class NeutronAristaCharm(charms_openstack.charm.OpenStackCharm):
|
||||||
configs.register(cfg, rscs['contexts'])
|
configs.register(cfg, rscs['contexts'])
|
||||||
return configs
|
return configs
|
||||||
|
|
||||||
|
|
||||||
class AristaMl2Context(context.OSContextGenerator):
|
class AristaMl2Context(context.OSContextGenerator):
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
|
|
|
@ -22,7 +22,6 @@ from charms_openstack.charm import (
|
||||||
use_defaults,
|
use_defaults,
|
||||||
)
|
)
|
||||||
import charm.openstack.neutron_arista as arista # noqa
|
import charm.openstack.neutron_arista as arista # noqa
|
||||||
from charm.openstack.neutron_arista import register_configs
|
|
||||||
|
|
||||||
|
|
||||||
use_defaults('update-status')
|
use_defaults('update-status')
|
||||||
|
|
|
@ -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
|
|
@ -15,13 +15,10 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import contextlib
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import charm.openstack.neutron_arista as neutron_arista
|
|
||||||
|
|
||||||
|
|
||||||
def FakeConfig(init_dict):
|
def FakeConfig(init_dict):
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import reactive.designate_handlers as handlers
|
import reactive.neutron_arista_handlers as handlers
|
||||||
|
|
||||||
import charms_openstack.test_utils as test_utils
|
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
|
# test that the hooks actually registered the relation expressions that
|
||||||
# are meaningful for this interface: this is to handle regressions.
|
# are meaningful for this interface: this is to handle regressions.
|
||||||
# The keys are the function names that the hook attaches to.
|
# The keys are the function names that the hook attaches to.
|
||||||
all_interfaces = (
|
|
||||||
'neutron-plugin-api-subordinate.connected', )
|
|
||||||
hook_set = {
|
hook_set = {
|
||||||
'when': {
|
'when': {
|
||||||
'configure_principle': (
|
'configure_principle': (
|
||||||
'neutron-plugin-api-subordinate.connected', ),
|
'neutron-plugin-api-subordinate.connected', ),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# test that the hooks were registered via the
|
# test that the hooks were registered via the
|
||||||
# reactive.barbican_handlers
|
# reactive.barbican_handlers
|
||||||
|
@ -37,5 +35,6 @@ class TestHandlers(test_utils.PatchHelper):
|
||||||
|
|
||||||
def test_configure_principal(self):
|
def test_configure_principal(self):
|
||||||
the_charm = self._patch_provide_charm_instance()
|
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()
|
the_charm.write_config.assert_called_once_with()
|
||||||
|
|
Loading…
Reference in New Issue