Tidy pep8 lint

This commit is contained in:
James Page 2017-07-06 17:20:49 +01:00
parent 20a0841aae
commit 6154bf4d2f
5 changed files with 10 additions and 142 deletions

View File

@ -13,7 +13,8 @@ import charms_openstack.ip as os_ip
GNOCCHI_DIR = '/etc/gnocchi'
GNOCCHI_CONF = os.path.join(GNOCCHI_DIR, 'gnocchi.conf')
GNOCCHI_APACHE_SITE = 'gnocchi-api'
GNOCCHI_WSGI_CONF = '/etc/apache2/sites-available/{}.conf'.format(GNOCCHI_APACHE_SITE)
GNOCCHI_WSGI_CONF = '/etc/apache2/sites-available/{}.conf'.format(
GNOCCHI_APACHE_SITE)
CEPH_CONF = '/etc/ceph/ceph.conf'
@ -21,6 +22,7 @@ CEPH_POOL_NAME = 'gnocchi'
class StorageCephRelationAdapter(adapters.OpenStackRelationAdapter):
"""
Adapter for the CephClientRequires relation interface.
"""
@ -41,6 +43,7 @@ class StorageCephRelationAdapter(adapters.OpenStackRelationAdapter):
class GnocchiCharmRelationAdapaters(adapters.OpenStackAPIRelationAdapters):
"""
Adapters collection to append ceph-client adapter for Gnocchi
"""
@ -53,6 +56,7 @@ class GnocchiCharmRelationAdapaters(adapters.OpenStackAPIRelationAdapters):
class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
"""
Charm for Juju deployment of Gnocchi
"""
@ -102,7 +106,6 @@ class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
]),
}
sync_cmd = ['gnocchi-upgrade']
adapters_class = GnocchiCharmRelationAdapaters
@ -129,4 +132,4 @@ class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
return [{
'database': 'gnocchi',
'username': 'gnocchi',
'hostname': hookenv.unit_private_ip() },]
'hostname': hookenv.unit_private_ip()}, ]

View File

@ -27,12 +27,13 @@ u = os_amulet_utils.OpenStackAmuletUtils(os_amulet_utils.DEBUG)
class GnocchiCharmDeployment(amulet_deployment.OpenStackAmuletDeployment):
"""Amulet tests on a basic gnocchi deployment."""
def __init__(self, series, openstack=None, source=None, stable=False):
"""Deploy the entire test environment."""
super(GnocchiCharmDeployment, self).__init__(series, openstack,
source, stable)
source, stable)
self._add_services()
self._add_relations()
self._configure_services()
@ -58,7 +59,7 @@ class GnocchiCharmDeployment(amulet_deployment.OpenStackAmuletDeployment):
{'name': 'keystone'},
]
super(GnocchiCharmDeployment, self)._add_services(this_service,
other_services)
other_services)
def _add_relations(self):
"""Add all of the relations for the services."""
@ -144,4 +145,4 @@ class GnocchiCharmDeployment(amulet_deployment.OpenStackAmuletDeployment):
if ret:
amulet.raise_status(amulet.FAIL, msg=ret)
u.log.debug('OK')
u.log.debug('OK')

View File

@ -1,46 +0,0 @@
# Copyright 2016 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import mock
sys.path.append('src')
sys.path.append('src/lib')
# Mock out charmhelpers so that we can test without it.
# also stops sideeffects from occuring.
charmhelpers = mock.MagicMock()
apt_pkg = mock.MagicMock()
sys.modules['apt_pkg'] = apt_pkg
sys.modules['charmhelpers'] = charmhelpers
sys.modules['charmhelpers.core'] = charmhelpers.core
sys.modules['charmhelpers.core.decorators'] = charmhelpers.core.decorators
sys.modules['charmhelpers.core.hookenv'] = charmhelpers.core.hookenv
sys.modules['charmhelpers.core.host'] = charmhelpers.core.host
sys.modules['charmhelpers.core.unitdata'] = charmhelpers.core.unitdata
sys.modules['charmhelpers.core.templating'] = charmhelpers.core.templating
sys.modules['charmhelpers.contrib'] = charmhelpers.contrib
sys.modules['charmhelpers.contrib.openstack'] = charmhelpers.contrib.openstack
sys.modules['charmhelpers.contrib.openstack.utils'] = (
charmhelpers.contrib.openstack.utils)
sys.modules['charmhelpers.contrib.openstack.templating'] = (
charmhelpers.contrib.openstack.templating)
sys.modules['charmhelpers.contrib.network'] = charmhelpers.contrib.network
sys.modules['charmhelpers.contrib.network.ip'] = (
charmhelpers.contrib.network.ip)
sys.modules['charmhelpers.fetch'] = charmhelpers.fetch
sys.modules['charmhelpers.cli'] = charmhelpers.cli
sys.modules['charmhelpers.contrib.hahelpers'] = charmhelpers.contrib.hahelpers
sys.modules['charmhelpers.contrib.hahelpers.cluster'] = (
charmhelpers.contrib.hahelpers.cluster)

View File

@ -1,47 +0,0 @@
# Copyright 2016 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from __future__ import print_function
import unittest
import mock
import charm.openstack.sdn_charm as sdn_charm
class Helper(unittest.TestCase):
def setUp(self):
self._patches = {}
self._patches_start = {}
def tearDown(self):
for k, v in self._patches.items():
v.stop()
setattr(self, k, None)
self._patches = None
self._patches_start = None
def patch(self, obj, attr, return_value=None, **kwargs):
mocked = mock.patch.object(obj, attr, **kwargs)
self._patches[attr] = mocked
started = mocked.start()
started.return_value = return_value
self._patches_start[attr] = started
setattr(self, attr, started)
class TestSDNCharm(Helper):

View File

@ -1,43 +0,0 @@
# Copyright 2016 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from __future__ import print_function
import mock
import reactive.sdn_charm_handlers as handlers
import charms_openstack.test_utils as test_utils
class TestRegisteredHooks(test_utils.TestRegisteredHooks):
def test_hooks(self):
defaults = [
'charm.installed',
'config.changed',
'update-status']
hook_set = {
'when': {
},
'when_not': {
}
}
# test that the hooks were registered via the
# reactive.barbican_handlers
self.registered_hooks_test_helper(handlers, hook_set, defaults)
class TestSDNCharmHandles(test_utils.PatchHelper):