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
|
||||
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):
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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 print_function
|
||||
|
||||
import contextlib
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
import charm.openstack.neutron_arista as neutron_arista
|
||||
|
||||
|
||||
def FakeConfig(init_dict):
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue