Updating hacking to 0.9.2 and associated styling fixes

Change-Id: Ibda11466db47e040ce3629d4290706488db831ce
This commit is contained in:
Lennart Regebro 2014-10-01 11:26:45 +02:00
parent b0506f09d8
commit 9242e1f40b
51 changed files with 91 additions and 114 deletions

View File

@ -6,7 +6,7 @@ set -o errexit
# Increment me any time the environment should be rebuilt.
# This includes dependency changes, directory renames, etc.
# Simple integer sequence: 1, 2, 3...
environment_version=44
environment_version=45
#--------------------------------------------------------#
function usage {

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8
hacking>=0.8.0,<0.9
hacking>=0.9.2,<0.10
# Testing Requirements
coverage>=3.6
django-nose

View File

@ -15,10 +15,8 @@ import urlparse
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon.utils import memoized
from openstack_dashboard.api import base
from openstack_dashboard.api import heat
from openstack_dashboard.api import keystone
@ -131,9 +129,9 @@ class Stack(base.APIResourceWrapper):
"""
# TODO(lsmola) until we have working deployment through Tuskar-API,
# this will not work
#for stack in Stack.list(request):
# if stack.plan and (stack.plan.id == plan.id):
# return stack
# for stack in Stack.list(request):
# if stack.plan and (stack.plan.id == plan.id):
# return stack
try:
stack = Stack.list(request)[0]
except IndexError:
@ -149,8 +147,10 @@ class Stack(base.APIResourceWrapper):
@memoized.memoized
def resources(self, with_joins=True, role=None):
"""Return list of OS::Nova::Server Resources associated with the Stack
and which are associated with a Role
"""Return list of OS::Nova::Server Resources
Return list of OS::Nova::Server Resources associated with the Stack
and which are associated with a Role
:param with_joins: should we also retrieve objects associated with each
retrieved Resource?
@ -228,8 +228,7 @@ class Stack(base.APIResourceWrapper):
@cached_property
def plan(self):
"""return associated Plan if a plan_id exists within stack
parameters.
"""return associated Plan if a plan_id exists within stack parameters.
:return: associated Plan if plan_id exists and a matching plan
exists as well; None otherwise
@ -238,9 +237,9 @@ class Stack(base.APIResourceWrapper):
# TODO(lsmola) replace this by actual reference, I am pretty sure
# the relation won't be stored in parameters, that would mean putting
# that into template, which doesn't make sense
#if 'plan_id' in self.parameters:
# return tuskar.Plan.get(self._request,
# self.parameters['plan_id'])
# if 'plan_id' in self.parameters:
# return tuskar.Plan.get(self._request,
# self.parameters['plan_id'])
try:
plan = tuskar.Plan.list(self._request)[0]
except IndexError:

View File

@ -75,8 +75,7 @@ class IronicNode(base.APIResourceWrapper):
memory_mb=None, local_gb=None, mac_addresses=[],
ipmi_username=None, ipmi_password=None, ssh_address=None,
ssh_username=None, ssh_key_contents=None, driver=None):
"""Create a Node in Ironic
"""
"""Create a Node in Ironic."""
if driver == 'pxe_ssh':
driver_info = {
'ssh_address': ssh_address,
@ -177,7 +176,9 @@ class IronicNode(base.APIResourceWrapper):
@classmethod
def delete(cls, request, uuid):
"""Remove the IronicNode matching the ID if it
"""Delete an IronicNode
Remove the IronicNode matching the ID if it
exists; otherwise, does nothing.
:param request: request object
@ -275,8 +276,7 @@ class BareMetalNode(base.APIResourceWrapper):
local_gb, mac_addresses, ipmi_username=None, ipmi_password=None,
ssh_address=None, ssh_username=None, ssh_key_contents=None,
driver=None):
"""Create a Nova BareMetalNode
"""
"""Create a Nova BareMetalNode."""
node = baremetalclient(request).create(
service_host='undercloud',
cpus=cpus,
@ -402,8 +402,7 @@ class BareMetalNode(base.APIResourceWrapper):
@cached_property
def driver(self):
"""Return driver for this BareMetalNode
"""
"""Return driver for this BareMetalNode."""
return "IPMI + PXE"
@cached_property

View File

@ -21,6 +21,7 @@ from openstack_dashboard.api import base
from openstack_dashboard.api import glance
from openstack_dashboard.api import neutron
from os_cloud_config import keystone_pki
from tuskarclient import client as tuskar_client
from tuskar_ui.api import flavor
@ -387,8 +388,7 @@ class Role(base.APIResourceWrapper):
@classmethod
@handle_errors(_("Unable to retrieve overcloud role"))
def get_by_image(cls, request, plan, image):
"""Return the Tuskar Role whose ImageID
parameter matches the passed in image
"""Return the Role whose ImageID parameter matches the image.
:param request: request object
:type request: django.http.HttpRequest

View File

@ -47,7 +47,9 @@
# So we have a copy of it here, with the bug fixed.
# FIXME: Use django's version when the bug is fixed there.
class cached_property(object):
"""Decorator that creates converts a method with a single self argument
"""Cached property decorator.
Decorator that creates converts a method with a single self argument
into a property cached on the instance.
"""

View File

@ -12,6 +12,7 @@
# under the License.
from openstack_dashboard import exceptions
from tuskarclient.openstack.common.apiclient import exceptions as tuskarclient
NOT_FOUND = exceptions.NOT_FOUND

View File

@ -16,7 +16,6 @@ import re
from django import forms
from django.utils import html
from django.utils.translation import ugettext_lazy as _
import netaddr
@ -119,10 +118,12 @@ class SelfHandlingFormset(forms.formsets.BaseFormSet):
class LabelWidget(forms.Widget):
"""This is a custom widget to show context information just as text,
as readonly inputs are confusing.
Note that the field also must be required=False, as no input
is rendered, and it must be ignored in the handle() method.
"""A widget for displaying information.
This is a custom widget to show context information just as text,
as readonly inputs are confusing.
Note that the field also must be required=False, as no input
is rendered, and it must be ignored in the handle() method.
"""
def render(self, name, value, attrs=None):
if value:

View File

@ -12,7 +12,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard

View File

@ -14,9 +14,8 @@
from django.utils.translation import ugettext_lazy as _
from horizon import tables
from openstack_dashboard.dashboards.admin.flavors \
import tables as flavor_tables
from openstack_dashboard.dashboards.admin.flavors import (
tables as flavor_tables)
from tuskar_ui import api

View File

@ -15,13 +15,11 @@
import contextlib
from django.core import urlresolvers
from mock import patch, call # noqa
from novaclient.v1_1 import servers
from horizon import exceptions
from mock import patch, call # noqa
from novaclient.v1_1 import servers
from openstack_dashboard.test.test_data import utils
from tuskar_ui import api
from tuskar_ui.test import helpers as test
from tuskar_ui.test.test_data import flavor_data
@ -110,7 +108,7 @@ class FlavorsTest(test.BaseAdminViewTests):
self.client.get(CREATE_URL)
# FIXME(tzumainn): I expected the following to work, seems similar
# to comment on test_index_recoverable_failure
#self.assertMessageCount(error=1, warning=0)
# self.assertMessageCount(error=1, warning=0)
def test_create_post_ok(self):
images = TEST_DATA.glanceclient_images.list()

View File

@ -14,7 +14,6 @@
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
import horizon.exceptions
import horizon.tables
import horizon.tabs

View File

@ -14,13 +14,12 @@
from django.forms import fields
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import workflows
from openstack_dashboard.api import glance
from openstack_dashboard.dashboards.admin.flavors \
import workflows as flavor_workflows
from openstack_dashboard.dashboards.admin.flavors import (
workflows as flavor_workflows)
from tuskar_ui import api

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
from horizon import tables

View File

@ -15,10 +15,9 @@
import contextlib
from django.core import urlresolvers
from mock import patch, call # noqa
from openstack_dashboard.test.test_data import utils
from tuskar_ui import api
from tuskar_ui.test import helpers as test
from tuskar_ui.test.test_data import heat_data

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard

View File

@ -13,12 +13,10 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
from horizon import tables
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.images.images \
import tables as project_tables
from openstack_dashboard.dashboards.project.images.images import (
tables as project_tables)
class CreateImage(project_tables.CreateImage):

View File

@ -14,11 +14,10 @@
import contextlib
import json
import mock
from mock import patch, call # noqa
from django.core import urlresolvers
from openstack_dashboard.dashboards.project.images.images import forms
from tuskar_ui import api

View File

@ -16,11 +16,9 @@ import logging
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tables as horizon_tables
from horizon.utils import memoized
from openstack_dashboard import api
from openstack_dashboard.dashboards.admin.images import views as admin_views
from openstack_dashboard.dashboards.project.images.images import views

View File

@ -13,11 +13,12 @@
# under the License.
import csv
import django.forms
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from tuskar_ui import api
import tuskar_ui.forms

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard

View File

@ -14,7 +14,6 @@
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from horizon import tables
from tuskar_ui import api

View File

@ -14,10 +14,8 @@
from django.core import urlresolvers
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from openstack_dashboard.api import base as api_base
from tuskar_ui import api

View File

@ -16,12 +16,11 @@ import contextlib
import json
from django.core import urlresolvers
from mock import patch, call # noqa
from horizon import exceptions as horizon_exceptions
from mock import patch, call # noqa
from openstack_dashboard.test import helpers
from openstack_dashboard.test.test_data import utils
from tuskar_ui import api
from tuskar_ui.handle_errors import handle_errors # noqa
from tuskar_ui.test import helpers as test

View File

@ -17,7 +17,6 @@ from django.core.urlresolvers import reverse_lazy
from django import http
from django.utils.translation import ugettext_lazy as _
from django.views.generic import base
from horizon import forms as horizon_forms
from horizon import tabs as horizon_tabs
from horizon.utils import memoized

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard

View File

@ -25,7 +25,9 @@ INDEX_URL = 'horizon:infrastructure:overview:index'
def _get_role_data(plan, stack, form, role):
"""Gathers data about a single deployment role from the related Overcloud
"""Gathers data about a single deployment role.
Gathers data about a single deployment role from the related Overcloud
and Role objects, and presents it in the form convenient for use
from the template.

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
from horizon import tables

View File

@ -19,6 +19,7 @@ from mock import patch, call # noqa
from openstack_dashboard.test.test_data import utils
from tuskar_ui import api
from tuskar_ui.infrastructure.parameters import views
from tuskar_ui.test import helpers as test
from tuskar_ui.test.test_data import tuskar_data
@ -31,8 +32,6 @@ SERVICE_CONFIG_URL = urlresolvers.reverse(
TEST_DATA = utils.TestDataContainer()
tuskar_data.data(TEST_DATA)
from tuskar_ui.infrastructure.parameters import views
class ParametersTest(test.BaseAdminViewTests):

View File

@ -41,7 +41,7 @@ class ServiceConfigView(horizon.forms.ModalFormView):
virt_type = plan.parameter_value(
compute_prefix + 'NovaComputeLibvirtType')
#TODO(tzumainn): what if compute and control values are different...
# TODO(tzumainn): what if compute and control values are different...
snmp_password = plan.parameter_value(
compute_prefix + 'SnmpdReadonlyUserPassword')

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
import horizon
from tuskar_ui.infrastructure import dashboard

View File

@ -13,7 +13,6 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
from horizon import tables
from tuskar_ui import api

View File

@ -13,11 +13,10 @@
# under the License.
import contextlib
from django.core import urlresolvers
from mock import patch, call # noqa
from openstack_dashboard.test.test_data import utils
from mock import patch, call # noqa
from tuskar_ui import api
from tuskar_ui.test import helpers as test

View File

@ -18,13 +18,11 @@ from django.core.urlresolvers import reverse_lazy
from django import http
from django.utils.translation import ugettext_lazy as _
from django.views.generic import base
from glanceclient import exc as glance_exc
from horizon import exceptions as horizon_exceptions
from horizon import tables as horizon_tables
from horizon import utils
from horizon import workflows
from openstack_dashboard.api import base as api_base
from tuskar_ui import api

View File

@ -13,12 +13,11 @@
# under the License.
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import forms
from horizon import workflows
from openstack_dashboard.api import glance
from tuskar_ui import api
from tuskar_ui import forms as tuskar_forms
from tuskar_ui.infrastructure.flavors import utils

View File

@ -45,9 +45,9 @@ def all_used_instances(obj):
info['popup_used'] = (
'<p> {0}% total,'
' <strong> {1} instances</strong> of {2}</p>'.format(
flavor.used_instances,
flavor.used_instances,
flavor.name))
flavor.used_instances,
flavor.used_instances,
flavor.name))
info['used_instances'] = str(flavor.used_instances)
all_used_instances_info.append(info)

View File

@ -14,10 +14,9 @@
from __future__ import absolute_import
from django.utils import unittest
from heatclient.v1 import events
import mock
from mock import patch # noqa
from heatclient.v1 import events
from novaclient.v1_1 import servers
from tuskar_ui import api

View File

@ -12,8 +12,8 @@
# under the License.
import django.forms
from horizon import tables
import tuskar_ui.tables
from tuskar_ui.test import helpers as test

View File

@ -16,8 +16,8 @@ import warnings
from django.core.handlers import wsgi
from django.utils import unittest
from openstack_dashboard.test import helpers as openstack_dashboard_helpers
from tuskar_ui.test.test_data import utils as test_data_utils
@ -37,8 +37,9 @@ def create_stubs(stubs_to_create={}):
@unittest.skipIf(os.environ.get('SKIP_UNITTESTS', False),
"The SKIP_UNITTESTS env variable is set.")
class TestCase(openstack_dashboard_helpers.TestCase):
"""Specialized base test case class for Horizon which gives access to
numerous additional features:
"""Specialized base test case class for Horizon.
TestCase gives access to numerous additional features:
* A full suite of test data through various attached objects and
managers (e.g. ``self.servers``, ``self.user``, etc.). See the
@ -69,8 +70,9 @@ class TestCase(openstack_dashboard_helpers.TestCase):
class BaseAdminViewTests(openstack_dashboard_helpers.BaseAdminViewTests):
"""A ``TestCase`` subclass which sets an active user with the "admin" role
for testing admin-only views and functionality.
"""A ``TestCase`` subclass which sets an active user with the "admin" role.
This is for testing admin-only views and functionality.
"""
def setUp(self):
super(BaseAdminViewTests, self).setUp()
@ -80,7 +82,9 @@ class BaseAdminViewTests(openstack_dashboard_helpers.BaseAdminViewTests):
class APITestCase(openstack_dashboard_helpers.APITestCase):
"""The ``APITestCase`` class is for use with tests which deal with the
"""TestCase for testing API clients.
The ``APITestCase`` class is for use with tests which deal with the
underlying clients rather than stubbing out the
openstack_dashboard.api.* methods.
"""

View File

@ -12,6 +12,7 @@
# under the License.
from openstack_dashboard.test.test_data import exceptions
from tuskarclient.openstack.common.apiclient import exceptions as tuskarclient

View File

@ -10,9 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack_dashboard.test.test_data import utils as test_data_utils
from novaclient.v1_1 import flavors
from openstack_dashboard.test.test_data import utils as test_data_utils
def data(TEST):

View File

@ -10,13 +10,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack_dashboard.test.test_data import utils as test_data_utils
from glanceclient.v1 import images
from heatclient.v1 import events
from heatclient.v1 import resources
from heatclient.v1 import stacks
from novaclient.v1_1 import servers
from openstack_dashboard.test.test_data import utils as test_data_utils
def data(TEST):

View File

@ -10,11 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack_dashboard.test.test_data import utils as test_data_utils
from ironicclient.v1 import node
from ironicclient.v1 import port
from novaclient.v1_1.contrib import baremetal
from openstack_dashboard.test.test_data import utils as test_data_utils
def data(TEST):

View File

@ -11,6 +11,7 @@
# under the License.
from openstack_dashboard.test.test_data import utils as test_data_utils
from tuskarclient.v2 import plans
from tuskarclient.v2 import roles

View File

@ -22,6 +22,7 @@ def load_test_data(load_onto=None):
from openstack_dashboard.test.test_data import neutron_data
from openstack_dashboard.test.test_data import nova_data
from openstack_dashboard.test.test_data import swift_data
from tuskar_ui.test.test_data import exceptions
from tuskar_ui.test.test_data import flavor_data
from tuskar_ui.test.test_data import heat_data as tuskar_heat_data

View File

@ -13,7 +13,6 @@
from django.conf import urls
from django.views import generic
import openstack_dashboard.urls
urlpatterns = urls.patterns(

View File

@ -12,16 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
from datetime import datetime # noqa
from datetime import timedelta # noqa
from django.utils.http import urlencode
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from openstack_dashboard.api import ceilometer
SETTINGS = {
@ -68,7 +65,7 @@ LABELS = {
}
#TODO(lsmola) this should probably live in Horizon common
# TODO(lsmola) this should probably live in Horizon common
def query_data(request,
date_from,
date_to,
@ -117,7 +114,7 @@ def query_data(request,
return resources, unit
#TODO(lsmola) push this function to Horizon common then delete this
# TODO(lsmola) push this function to Horizon common then delete this
def _calc_period(date_from, date_to, number_of_samples=400):
if date_from and date_to:
if date_to < date_from:
@ -136,7 +133,7 @@ def _calc_period(date_from, date_to, number_of_samples=400):
return period
#TODO(lsmola) push this function to Horizon common then delete this
# TODO(lsmola) push this function to Horizon common then delete this
def _calc_date_args(date_from, date_to, date_options):
# TODO(lsmola) all timestamps should probably work with
# current timezone. And also show the current timezone in chart.
@ -198,8 +195,7 @@ def get_barchart_stats(series, unit):
'%(first_date)s, to: %(last_date)s') % (
dict(average=average, unit=unit,
first_date=first_date,
last_date=last_date)
)
last_date=last_date))
return average, used, tooltip_average

View File

@ -15,7 +15,6 @@ import logging
from django import template
from django.utils import datastructures
import horizon.workflows
@ -29,7 +28,9 @@ class WorkflowView(horizon.workflows.WorkflowView):
# FIXME: TableStep
class TableStep(horizon.workflows.Step):
"""A :class:`~horizon.workflows.Step` class which knows how to deal with
"""A Step class with DataTables.
A :class:`~horizon.workflows.Step` class which knows how to deal with
:class:`~horizon.tables.DataTable` classes rendered inside of it.
This distinct class is required due to the complexity involved in handling
@ -63,6 +64,7 @@ class TableStep(horizon.workflows.Step):
def prepare_action_context(self, request, context):
"""Passes the tables to the action for validation and data extraction.
"""
self.load_table_data()
context['_tables'] = self._tables
@ -82,7 +84,9 @@ class TableStep(horizon.workflows.Step):
return step_template.render(context)
def load_table_data(self):
"""Calls the ``get_{{ table_name }}_data`` methods for each table class
"""Sets table data.
Calls the ``get_{{ table_name }}_data`` methods for each table class
and sets the data on the tables.
"""
# We only want the data to be loaded once, so we track if we have...
@ -102,7 +106,9 @@ class TableStep(horizon.workflows.Step):
self._table_data_loaded = True
def get_context_data(self, request):
"""Adds a ``{{ table_name }}_table`` item to the context for each table
"""Gets the table contexct data.
Adds a ``{{ table_name }}_table`` item to the context for each table
in the :attr:`~horizon.tabs.TableTab.table_classes` attribute.
If only one table class is provided, a shortcut ``table`` context