Merge pull request #6 from ediardo/removingPEP8errors
Removed PEP8 errors
This commit is contained in:
commit
57ffeddc2f
@ -17,8 +17,10 @@ from craton_dashboard.test import helpers as test
|
||||
|
||||
|
||||
class CratonApiTests(test.CratonAPITestCase):
|
||||
"""Tests for Craton APIs."""
|
||||
|
||||
def test_regions_list(self):
|
||||
"""Test for getting all regions."""
|
||||
regions = self.craton_regions.list()
|
||||
cratonclient = self.stub_cratonclient()
|
||||
cratonclient.regions = self.mox.CreateMockAnything()
|
||||
|
@ -1 +0,0 @@
|
||||
from craton_dashboard.api import craton
|
@ -12,12 +12,10 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from six.moves.urllib import request
|
||||
from django.conf import settings
|
||||
from cratonclient.v1 import client as craton_client
|
||||
|
||||
from horizon import exceptions
|
||||
from cratonclient.v1 import client as craton_client
|
||||
from openstack_dashboard.api import base
|
||||
from six.moves.urllib import request
|
||||
|
||||
|
||||
def cratonclient():
|
||||
@ -25,24 +23,31 @@ def cratonclient():
|
||||
c = craton_client.Client(session=request.session, url=url)
|
||||
return c
|
||||
|
||||
|
||||
def project_create(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def project_delete(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def project_list(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def project_show(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def project_update(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def region_create(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def region_delete(request, **kwargs):
|
||||
pass
|
||||
|
||||
@ -50,53 +55,70 @@ def region_delete(request, **kwargs):
|
||||
def region_list(request, **kwargs):
|
||||
return cratonclient(request).regions.list(**kwargs)
|
||||
|
||||
|
||||
def region_show(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def region_update(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def cell_create(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def cell_delete(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def cell_list(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def cell_show(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def cell_update(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def device_create(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def device_delete(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def device_list(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def device_show(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def host_create(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def host_delete(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def host_list(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def host_show(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def host_update(request, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def user_list(request, **kwargs):
|
||||
pass
|
||||
|
@ -1 +0,0 @@
|
||||
from craton_dashboard.api.rest import craton
|
@ -12,95 +12,92 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from django.views import generic
|
||||
|
||||
from craton_dashboard.api import craton
|
||||
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.api.rest import urls
|
||||
from openstack_dashboard.api.rest import utils as rest_utils
|
||||
|
||||
from six.moves.urllib import request
|
||||
|
||||
@urls.register
|
||||
class Regions(generic.View):
|
||||
"""API for craton"""
|
||||
"""API for craton."""
|
||||
|
||||
url_regex = r'craton/regions/$'
|
||||
|
||||
@rest_utils.ajax()
|
||||
def get(self, request, **kwargs):
|
||||
"""Gets all Regions"""
|
||||
"""Get all Regions."""
|
||||
regions = craton.region_list(request)
|
||||
return {'items': regions}
|
||||
|
||||
@rest_utils.ajax()
|
||||
def post(self, request, **kwargs):
|
||||
"""Creates a new Region"""
|
||||
"""Create a new Region."""
|
||||
return craton.region_create(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def put(self, request, **kwargs):
|
||||
"""Updates a Region"""
|
||||
"""Update a Region."""
|
||||
return craton.region_update(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def delete(self, request, **kwargs):
|
||||
"""Deletes a Region"""
|
||||
"""Delete a Region."""
|
||||
return craton.region_delete(request)
|
||||
|
||||
|
||||
@urls.register
|
||||
class Cells(generic.View):
|
||||
"""API for craton"""
|
||||
"""API for craton."""
|
||||
|
||||
url_regex = r'craton/cells/$'
|
||||
|
||||
@rest_utils.ajax()
|
||||
def get(self, request, **kwargs):
|
||||
"""Gets all Cells"""
|
||||
"""Get all Cells."""
|
||||
return craton.cell_list(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def post(self, request, **kwargs):
|
||||
"""Creates a new Cell"""
|
||||
"""Create a new Cell."""
|
||||
return craton.cell_create(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def put(self, request, **kwargs):
|
||||
"""Updates a Cell"""
|
||||
"""Update a Cell."""
|
||||
return craton.cell_update(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def delete(self, request, **kwargs):
|
||||
"""Deletes a Cell"""
|
||||
"""Delete a Cell."""
|
||||
return craton.cell_delete(request)
|
||||
|
||||
|
||||
@urls.register
|
||||
class Hosts(generic.View):
|
||||
"""API for craton"""
|
||||
"""API for craton."""
|
||||
|
||||
url_regex = r'craton/hosts/$'
|
||||
|
||||
@rest_utils.ajax()
|
||||
def get(self, request, **kwargs):
|
||||
"""Gets all Hosts"""
|
||||
"""Get all Hosts."""
|
||||
return craton.host_list(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def post(self, request, **kwargs):
|
||||
"""Creates a new Host"""
|
||||
"""Create a new Host."""
|
||||
return craton.hosts_create(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def put(self, request, **kwargs):
|
||||
"""Updates a Host"""
|
||||
"""Update a Host."""
|
||||
return craton.hosts_update(request)
|
||||
|
||||
@rest_utils.ajax()
|
||||
def delete(self, request, **kwargs):
|
||||
"""Deletes a Host"""
|
||||
"""Delete a Host."""
|
||||
return craton.hosts_delete(request)
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
from craton_dashboard.api import rest
|
@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
|
||||
class Inventory(horizon.Panel):
|
||||
name = _('Inventory')
|
||||
slug = 'fleet.inventory'
|
||||
|
@ -5,4 +5,3 @@ from craton_dashboard.content.fleet_management.inventory import views
|
||||
urlpatterns = [
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
]
|
||||
|
||||
|
@ -15,11 +15,7 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views import generic
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tables
|
||||
|
||||
class IndexView(generic.TemplateView):
|
||||
template_name = 'project/fleet.inventory/index.html'
|
||||
page_title = _('Inventory')
|
||||
|
||||
|
@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
|
||||
class Taskflows(horizon.Panel):
|
||||
name = _('Taskflows')
|
||||
slug = 'fleet.taskflows'
|
||||
|
@ -5,4 +5,3 @@ from craton_dashboard.content.fleet_management.taskflows import views
|
||||
urlpatterns = [
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
]
|
||||
|
||||
|
@ -15,11 +15,7 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views import generic
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
from horizon import tables
|
||||
|
||||
class IndexView(generic.TemplateView):
|
||||
template_name = 'project/fleet.taskflows/index.html'
|
||||
page_title = _('Taskflows')
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
PANEL = 'fleet.taskflows'
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
PANEL = 'fleet.inventory'
|
||||
|
||||
@ -22,4 +21,3 @@ PANEL_GROUP = 'fleet_management'
|
||||
|
||||
ADD_PANEL = (
|
||||
'craton_dashboard.content.fleet_management.inventory.panel.Inventory')
|
||||
|
||||
|
@ -39,9 +39,11 @@ class CratonTestsMixin(object):
|
||||
class TestCase(CratonTestsMixin, helpers.TestCase):
|
||||
pass
|
||||
|
||||
|
||||
class BaseAdminViewTests(CratonTestsMixin, helpers.TestCase):
|
||||
pass
|
||||
|
||||
|
||||
class CratonAPITestCase(CratonTestsMixin, helpers.APITestCase):
|
||||
def setUp(self):
|
||||
super(CratonAPITestCase, self).setUp()
|
||||
|
@ -15,3 +15,4 @@ from openstack_dashboard.test.settings import * # noqa
|
||||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
# INSTALLED_APPS.append('craton_dashboard.dashboards.project.fleet.inventory')
|
||||
INSTALLED_APPS.append('craton_dashboard.content.fleet_management')
|
||||
|
@ -16,6 +16,7 @@ from cratonclient.v1 import regions
|
||||
|
||||
from openstack_dashboard.test.test_data import utils
|
||||
|
||||
|
||||
def data(TEST):
|
||||
URL = 'http://localhost/'
|
||||
TEST.craton_regions = utils.TestDataContainer()
|
||||
|
@ -16,6 +16,11 @@ from openstack_dashboard.test.test_data import utils
|
||||
|
||||
|
||||
def load_test_data(load_onto=None):
|
||||
|
||||
from craton_dashboard.test.test_data import craton_data
|
||||
from craton_dashboard.test.test_data import keystone_data \
|
||||
as craton_keystone_data
|
||||
|
||||
from openstack_dashboard.test.test_data import ceilometer_data
|
||||
from openstack_dashboard.test.test_data import cinder_data
|
||||
from openstack_dashboard.test.test_data import exceptions
|
||||
@ -26,10 +31,6 @@ def load_test_data(load_onto=None):
|
||||
from openstack_dashboard.test.test_data import nova_data
|
||||
from openstack_dashboard.test.test_data import swift_data
|
||||
|
||||
from craton_dashboard.test.test_data import keystone_data \
|
||||
as craton_keystone_data
|
||||
from craton_dashboard.test.test_data import craton_data
|
||||
|
||||
# The order of these loaders matters, some depend on others.
|
||||
loaders = (
|
||||
exceptions.data,
|
||||
|
@ -3,8 +3,6 @@
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
hacking<0.12,>=0.10.0
|
||||
flake8_docstrings==0.2.1.post1 # MIT
|
||||
|
||||
coverage>=3.6
|
||||
ddt>=1.0.1 # MIT
|
||||
django-nose>=1.4.4 # BSD
|
||||
|
@ -36,16 +36,16 @@ PIP_INSTALL_WRAPPER = os.path.join(ROOT, 'tools', 'pip_install.sh')
|
||||
|
||||
|
||||
def die(message, *args):
|
||||
print >> sys.stderr, message % args
|
||||
print(sys.stderr, message % args)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def run_command(cmd, redirect_output=True, check_exit_code=True, cwd=ROOT,
|
||||
die_message=None):
|
||||
"""
|
||||
Runs a command in an out-of-process shell, returning the
|
||||
output of that command. Working directory is ROOT.
|
||||
"""
|
||||
|
||||
Run a command in an out-of-process shell, returning the
|
||||
output of that command. Working directory is ROOT."""
|
||||
if redirect_output:
|
||||
stdout = subprocess.PIPE
|
||||
else:
|
||||
@ -69,45 +69,44 @@ HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
|
||||
|
||||
def check_dependencies():
|
||||
"""Make sure virtualenv is in the path."""
|
||||
|
||||
print ('Checking dependencies...')
|
||||
print('Checking dependencies...')
|
||||
if not HAS_VIRTUALENV:
|
||||
print ('Virtual environment not found.')
|
||||
# Try installing it via easy_install...
|
||||
if HAS_EASY_INSTALL:
|
||||
print ('Installing virtualenv via easy_install...',
|
||||
run_command(['easy_install', 'virtualenv'],
|
||||
die_message=
|
||||
'easy_install failed to install virtualenv'
|
||||
'\ndevelopment requires virtualenv, please'
|
||||
' install it using your favorite tool'))
|
||||
die_message='easy_install failed to install '
|
||||
'virtualenv\ndevelopment requires '
|
||||
'virtualenv, please install it '
|
||||
'using your favorite tool'))
|
||||
if not run_command(['which', 'virtualenv']):
|
||||
die('ERROR: virtualenv not found in path.\n\ndevelopment '
|
||||
' requires virtualenv, please install it using your'
|
||||
' favorite package management tool and ensure'
|
||||
' virtualenv is in your path')
|
||||
print ('virtualenv installation done.')
|
||||
print('virtualenv installation done.')
|
||||
else:
|
||||
die('easy_install not found.\n\nInstall easy_install'
|
||||
' (python-setuptools in ubuntu) or virtualenv by hand,'
|
||||
' then rerun.')
|
||||
print ('dependency check done.')
|
||||
print('dependency check done.')
|
||||
|
||||
|
||||
def create_virtualenv(venv=VENV):
|
||||
"""Creates the virtual environment and installs PIP only into the
|
||||
virtual environment
|
||||
"""
|
||||
print 'Creating venv...',
|
||||
print('Creating venv...'),
|
||||
run_command(['virtualenv', '-q', '--no-site-packages', VENV])
|
||||
print 'done.'
|
||||
print 'Installing pip in virtualenv...',
|
||||
print('done.')
|
||||
print('Installing pip in virtualenv...'),
|
||||
if not run_command([WITH_VENV, 'easy_install', 'pip']).strip():
|
||||
die("Failed to install pip.")
|
||||
print 'done.'
|
||||
print 'Installing distribute in virtualenv...'
|
||||
print('done.')
|
||||
print('Installing distribute in virtualenv...')
|
||||
pip_install('distribute>=0.6.24')
|
||||
print 'done.'
|
||||
print('done.')
|
||||
|
||||
|
||||
def pip_install(*args):
|
||||
@ -121,8 +120,8 @@ def pip_install_with_horizon(*args):
|
||||
|
||||
|
||||
def install_dependencies(venv=VENV):
|
||||
print "Installing dependencies..."
|
||||
print "(This may take several minutes, don't panic)"
|
||||
print("Installing dependencies...")
|
||||
print("(This may take several minutes, don't panic)")
|
||||
pip_install_with_horizon('-r', TEST_REQUIRES)
|
||||
pip_install_with_horizon('-r', PIP_REQUIRES)
|
||||
|
||||
@ -134,7 +133,7 @@ def install_dependencies(venv=VENV):
|
||||
|
||||
|
||||
def install_horizon():
|
||||
print 'Installing horizon module in development mode...'
|
||||
print('Installing horizon module in development mode...')
|
||||
run_command([WITH_VENV, 'python', 'setup.py', 'develop'], cwd=ROOT)
|
||||
|
||||
|
||||
@ -145,7 +144,7 @@ To activate the virtualenv for the extent of your current shell session you
|
||||
can run:
|
||||
$ source .venv/bin/activate
|
||||
"""
|
||||
print summary
|
||||
print(summary)
|
||||
|
||||
|
||||
def main():
|
||||
|
8
tox.ini
8
tox.ini
@ -28,7 +28,7 @@ commands = {posargs}
|
||||
|
||||
[testenv:venv-constraints]
|
||||
install_command = {[testenv:common-constraints]install_command}
|
||||
commands = {posargs}
|
||||
commands = {posargs
|
||||
|
||||
[testenv:cover]
|
||||
commands = python setup.py test --coverage --testr-args='{posargs}'
|
||||
@ -53,8 +53,8 @@ commands = oslo_debug_helper {posargs}
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
|
||||
# H405 multi line docstring summary not separated with an empty line
|
||||
show-source = True
|
||||
ignore = E123,E125
|
||||
ignore = E123,E125,H405
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,setup.py
|
||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,.ropeproject,tools
|
||||
|
Loading…
Reference in New Issue
Block a user