Merge pull request #6 from ediardo/removingPEP8errors

Removed PEP8 errors
This commit is contained in:
Eddie Ramirez 2016-08-16 15:59:22 -05:00 committed by GitHub
commit 57ffeddc2f
21 changed files with 81 additions and 72 deletions

View File

@ -17,8 +17,10 @@ from craton_dashboard.test import helpers as test
class CratonApiTests(test.CratonAPITestCase): class CratonApiTests(test.CratonAPITestCase):
"""Tests for Craton APIs."""
def test_regions_list(self): def test_regions_list(self):
"""Test for getting all regions."""
regions = self.craton_regions.list() regions = self.craton_regions.list()
cratonclient = self.stub_cratonclient() cratonclient = self.stub_cratonclient()
cratonclient.regions = self.mox.CreateMockAnything() cratonclient.regions = self.mox.CreateMockAnything()

View File

@ -1 +0,0 @@
from craton_dashboard.api import craton

View File

@ -12,12 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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 openstack_dashboard.api import base
from six.moves.urllib import request
def cratonclient(): def cratonclient():
@ -25,24 +23,31 @@ def cratonclient():
c = craton_client.Client(session=request.session, url=url) c = craton_client.Client(session=request.session, url=url)
return c return c
def project_create(request, **kwargs): def project_create(request, **kwargs):
pass pass
def project_delete(request, **kwargs): def project_delete(request, **kwargs):
pass pass
def project_list(request, **kwargs): def project_list(request, **kwargs):
pass pass
def project_show(request, **kwargs): def project_show(request, **kwargs):
pass pass
def project_update(request, **kwargs): def project_update(request, **kwargs):
pass pass
def region_create(request, **kwargs): def region_create(request, **kwargs):
pass pass
def region_delete(request, **kwargs): def region_delete(request, **kwargs):
pass pass
@ -50,53 +55,70 @@ def region_delete(request, **kwargs):
def region_list(request, **kwargs): def region_list(request, **kwargs):
return cratonclient(request).regions.list(**kwargs) return cratonclient(request).regions.list(**kwargs)
def region_show(request, **kwargs): def region_show(request, **kwargs):
pass pass
def region_update(request, **kwargs): def region_update(request, **kwargs):
pass pass
def cell_create(request, **kwargs): def cell_create(request, **kwargs):
pass pass
def cell_delete(request, **kwargs): def cell_delete(request, **kwargs):
pass pass
def cell_list(request, **kwargs): def cell_list(request, **kwargs):
pass pass
def cell_show(request, **kwargs): def cell_show(request, **kwargs):
pass pass
def cell_update(request, **kwargs): def cell_update(request, **kwargs):
pass pass
def device_create(request, **kwargs): def device_create(request, **kwargs):
pass pass
def device_delete(request, **kwargs): def device_delete(request, **kwargs):
pass pass
def device_list(request, **kwargs): def device_list(request, **kwargs):
pass pass
def device_show(request, **kwargs): def device_show(request, **kwargs):
pass pass
def host_create(request, **kwargs): def host_create(request, **kwargs):
pass pass
def host_delete(request, **kwargs): def host_delete(request, **kwargs):
pass pass
def host_list(request, **kwargs): def host_list(request, **kwargs):
pass pass
def host_show(request, **kwargs): def host_show(request, **kwargs):
pass pass
def host_update(request, **kwargs): def host_update(request, **kwargs):
pass pass
def user_list(request, **kwargs): def user_list(request, **kwargs):
pass pass

View File

@ -1 +0,0 @@
from craton_dashboard.api.rest import craton

View File

@ -12,95 +12,92 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from django.conf import settings
from django.views import generic from django.views import generic
from craton_dashboard.api import craton from craton_dashboard.api import craton
from openstack_dashboard import api
from openstack_dashboard.api.rest import urls from openstack_dashboard.api.rest import urls
from openstack_dashboard.api.rest import utils as rest_utils from openstack_dashboard.api.rest import utils as rest_utils
from six.moves.urllib import request
@urls.register @urls.register
class Regions(generic.View): class Regions(generic.View):
"""API for craton""" """API for craton."""
url_regex = r'craton/regions/$' url_regex = r'craton/regions/$'
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, **kwargs): def get(self, request, **kwargs):
"""Gets all Regions""" """Get all Regions."""
regions = craton.region_list(request) regions = craton.region_list(request)
return {'items': regions} return {'items': regions}
@rest_utils.ajax() @rest_utils.ajax()
def post(self, request, **kwargs): def post(self, request, **kwargs):
"""Creates a new Region""" """Create a new Region."""
return craton.region_create(request) return craton.region_create(request)
@rest_utils.ajax() @rest_utils.ajax()
def put(self, request, **kwargs): def put(self, request, **kwargs):
"""Updates a Region""" """Update a Region."""
return craton.region_update(request) return craton.region_update(request)
@rest_utils.ajax() @rest_utils.ajax()
def delete(self, request, **kwargs): def delete(self, request, **kwargs):
"""Deletes a Region""" """Delete a Region."""
return craton.region_delete(request) return craton.region_delete(request)
@urls.register @urls.register
class Cells(generic.View): class Cells(generic.View):
"""API for craton""" """API for craton."""
url_regex = r'craton/cells/$' url_regex = r'craton/cells/$'
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, **kwargs): def get(self, request, **kwargs):
"""Gets all Cells""" """Get all Cells."""
return craton.cell_list(request) return craton.cell_list(request)
@rest_utils.ajax() @rest_utils.ajax()
def post(self, request, **kwargs): def post(self, request, **kwargs):
"""Creates a new Cell""" """Create a new Cell."""
return craton.cell_create(request) return craton.cell_create(request)
@rest_utils.ajax() @rest_utils.ajax()
def put(self, request, **kwargs): def put(self, request, **kwargs):
"""Updates a Cell""" """Update a Cell."""
return craton.cell_update(request) return craton.cell_update(request)
@rest_utils.ajax() @rest_utils.ajax()
def delete(self, request, **kwargs): def delete(self, request, **kwargs):
"""Deletes a Cell""" """Delete a Cell."""
return craton.cell_delete(request) return craton.cell_delete(request)
@urls.register @urls.register
class Hosts(generic.View): class Hosts(generic.View):
"""API for craton""" """API for craton."""
url_regex = r'craton/hosts/$' url_regex = r'craton/hosts/$'
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, **kwargs): def get(self, request, **kwargs):
"""Gets all Hosts""" """Get all Hosts."""
return craton.host_list(request) return craton.host_list(request)
@rest_utils.ajax() @rest_utils.ajax()
def post(self, request, **kwargs): def post(self, request, **kwargs):
"""Creates a new Host""" """Create a new Host."""
return craton.hosts_create(request) return craton.hosts_create(request)
@rest_utils.ajax() @rest_utils.ajax()
def put(self, request, **kwargs): def put(self, request, **kwargs):
"""Updates a Host""" """Update a Host."""
return craton.hosts_update(request) return craton.hosts_update(request)
@rest_utils.ajax() @rest_utils.ajax()
def delete(self, request, **kwargs): def delete(self, request, **kwargs):
"""Deletes a Host""" """Delete a Host."""
return craton.hosts_delete(request) return craton.hosts_delete(request)

View File

@ -1 +0,0 @@
from craton_dashboard.api import rest

View File

@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
import horizon import horizon
class Inventory(horizon.Panel): class Inventory(horizon.Panel):
name = _('Inventory') name = _('Inventory')
slug = 'fleet.inventory' slug = 'fleet.inventory'

View File

@ -5,4 +5,3 @@ from craton_dashboard.content.fleet_management.inventory import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'), url(r'^$', views.IndexView.as_view(), name='index'),
] ]

View File

@ -15,11 +15,7 @@
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views import generic from django.views import generic
from horizon import exceptions
from horizon import forms
from horizon import tables
class IndexView(generic.TemplateView): class IndexView(generic.TemplateView):
template_name = 'project/fleet.inventory/index.html' template_name = 'project/fleet.inventory/index.html'
page_title = _('Inventory') page_title = _('Inventory')

View File

@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
import horizon import horizon
class Taskflows(horizon.Panel): class Taskflows(horizon.Panel):
name = _('Taskflows') name = _('Taskflows')
slug = 'fleet.taskflows' slug = 'fleet.taskflows'

View File

@ -5,4 +5,3 @@ from craton_dashboard.content.fleet_management.taskflows import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'), url(r'^$', views.IndexView.as_view(), name='index'),
] ]

View File

@ -15,11 +15,7 @@
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views import generic from django.views import generic
from horizon import exceptions
from horizon import forms
from horizon import tables
class IndexView(generic.TemplateView): class IndexView(generic.TemplateView):
template_name = 'project/fleet.taskflows/index.html' template_name = 'project/fleet.taskflows/index.html'
page_title = _('Taskflows') page_title = _('Taskflows')

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from django.utils.translation import ugettext_lazy as _
PANEL = 'fleet.taskflows' PANEL = 'fleet.taskflows'

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from django.utils.translation import ugettext_lazy as _
PANEL = 'fleet.inventory' PANEL = 'fleet.inventory'
@ -22,4 +21,3 @@ PANEL_GROUP = 'fleet_management'
ADD_PANEL = ( ADD_PANEL = (
'craton_dashboard.content.fleet_management.inventory.panel.Inventory') 'craton_dashboard.content.fleet_management.inventory.panel.Inventory')

View File

@ -39,9 +39,11 @@ class CratonTestsMixin(object):
class TestCase(CratonTestsMixin, helpers.TestCase): class TestCase(CratonTestsMixin, helpers.TestCase):
pass pass
class BaseAdminViewTests(CratonTestsMixin, helpers.TestCase): class BaseAdminViewTests(CratonTestsMixin, helpers.TestCase):
pass pass
class CratonAPITestCase(CratonTestsMixin, helpers.APITestCase): class CratonAPITestCase(CratonTestsMixin, helpers.APITestCase):
def setUp(self): def setUp(self):
super(CratonAPITestCase, self).setUp() super(CratonAPITestCase, self).setUp()

View File

@ -15,3 +15,4 @@ from openstack_dashboard.test.settings import * # noqa
INSTALLED_APPS = list(INSTALLED_APPS) INSTALLED_APPS = list(INSTALLED_APPS)
# INSTALLED_APPS.append('craton_dashboard.dashboards.project.fleet.inventory') # INSTALLED_APPS.append('craton_dashboard.dashboards.project.fleet.inventory')
INSTALLED_APPS.append('craton_dashboard.content.fleet_management')

View File

@ -16,6 +16,7 @@ from cratonclient.v1 import regions
from openstack_dashboard.test.test_data import utils from openstack_dashboard.test.test_data import utils
def data(TEST): def data(TEST):
URL = 'http://localhost/' URL = 'http://localhost/'
TEST.craton_regions = utils.TestDataContainer() TEST.craton_regions = utils.TestDataContainer()

View File

@ -16,6 +16,11 @@ from openstack_dashboard.test.test_data import utils
def load_test_data(load_onto=None): 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 ceilometer_data
from openstack_dashboard.test.test_data import cinder_data from openstack_dashboard.test.test_data import cinder_data
from openstack_dashboard.test.test_data import exceptions 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 nova_data
from openstack_dashboard.test.test_data import swift_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. # The order of these loaders matters, some depend on others.
loaders = ( loaders = (
exceptions.data, exceptions.data,

View File

@ -3,8 +3,6 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking<0.12,>=0.10.0 hacking<0.12,>=0.10.0
flake8_docstrings==0.2.1.post1 # MIT
coverage>=3.6 coverage>=3.6
ddt>=1.0.1 # MIT ddt>=1.0.1 # MIT
django-nose>=1.4.4 # BSD django-nose>=1.4.4 # BSD

View File

@ -36,16 +36,16 @@ PIP_INSTALL_WRAPPER = os.path.join(ROOT, 'tools', 'pip_install.sh')
def die(message, *args): def die(message, *args):
print >> sys.stderr, message % args print(sys.stderr, message % args)
sys.exit(1) sys.exit(1)
def run_command(cmd, redirect_output=True, check_exit_code=True, cwd=ROOT, def run_command(cmd, redirect_output=True, check_exit_code=True, cwd=ROOT,
die_message=None): 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: if redirect_output:
stdout = subprocess.PIPE stdout = subprocess.PIPE
else: else:
@ -69,45 +69,44 @@ HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
def check_dependencies(): def check_dependencies():
"""Make sure virtualenv is in the path.""" """Make sure virtualenv is in the path."""
print('Checking dependencies...')
print ('Checking dependencies...')
if not HAS_VIRTUALENV: if not HAS_VIRTUALENV:
print ('Virtual environment not found.') print ('Virtual environment not found.')
# Try installing it via easy_install... # Try installing it via easy_install...
if HAS_EASY_INSTALL: if HAS_EASY_INSTALL:
print ('Installing virtualenv via easy_install...', print ('Installing virtualenv via easy_install...',
run_command(['easy_install', 'virtualenv'], run_command(['easy_install', 'virtualenv'],
die_message= die_message='easy_install failed to install '
'easy_install failed to install virtualenv' 'virtualenv\ndevelopment requires '
'\ndevelopment requires virtualenv, please' 'virtualenv, please install it '
' install it using your favorite tool')) 'using your favorite tool'))
if not run_command(['which', 'virtualenv']): if not run_command(['which', 'virtualenv']):
die('ERROR: virtualenv not found in path.\n\ndevelopment ' die('ERROR: virtualenv not found in path.\n\ndevelopment '
' requires virtualenv, please install it using your' ' requires virtualenv, please install it using your'
' favorite package management tool and ensure' ' favorite package management tool and ensure'
' virtualenv is in your path') ' virtualenv is in your path')
print ('virtualenv installation done.') print('virtualenv installation done.')
else: else:
die('easy_install not found.\n\nInstall easy_install' die('easy_install not found.\n\nInstall easy_install'
' (python-setuptools in ubuntu) or virtualenv by hand,' ' (python-setuptools in ubuntu) or virtualenv by hand,'
' then rerun.') ' then rerun.')
print ('dependency check done.') print('dependency check done.')
def create_virtualenv(venv=VENV): def create_virtualenv(venv=VENV):
"""Creates the virtual environment and installs PIP only into the """Creates the virtual environment and installs PIP only into the
virtual environment virtual environment
""" """
print 'Creating venv...', print('Creating venv...'),
run_command(['virtualenv', '-q', '--no-site-packages', VENV]) run_command(['virtualenv', '-q', '--no-site-packages', VENV])
print 'done.' print('done.')
print 'Installing pip in virtualenv...', print('Installing pip in virtualenv...'),
if not run_command([WITH_VENV, 'easy_install', 'pip']).strip(): if not run_command([WITH_VENV, 'easy_install', 'pip']).strip():
die("Failed to install pip.") die("Failed to install pip.")
print 'done.' print('done.')
print 'Installing distribute in virtualenv...' print('Installing distribute in virtualenv...')
pip_install('distribute>=0.6.24') pip_install('distribute>=0.6.24')
print 'done.' print('done.')
def pip_install(*args): def pip_install(*args):
@ -121,8 +120,8 @@ def pip_install_with_horizon(*args):
def install_dependencies(venv=VENV): def install_dependencies(venv=VENV):
print "Installing dependencies..." print("Installing dependencies...")
print "(This may take several minutes, don't panic)" print("(This may take several minutes, don't panic)")
pip_install_with_horizon('-r', TEST_REQUIRES) pip_install_with_horizon('-r', TEST_REQUIRES)
pip_install_with_horizon('-r', PIP_REQUIRES) pip_install_with_horizon('-r', PIP_REQUIRES)
@ -134,7 +133,7 @@ def install_dependencies(venv=VENV):
def install_horizon(): 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) 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: can run:
$ source .venv/bin/activate $ source .venv/bin/activate
""" """
print summary print(summary)
def main(): def main():

View File

@ -28,7 +28,7 @@ commands = {posargs}
[testenv:venv-constraints] [testenv:venv-constraints]
install_command = {[testenv:common-constraints]install_command} install_command = {[testenv:common-constraints]install_command}
commands = {posargs} commands = {posargs
[testenv:cover] [testenv:cover]
commands = python setup.py test --coverage --testr-args='{posargs}' commands = python setup.py test --coverage --testr-args='{posargs}'
@ -53,8 +53,8 @@ commands = oslo_debug_helper {posargs}
[flake8] [flake8]
# E123, E125 skipped as they are invalid PEP-8. # E123, E125 skipped as they are invalid PEP-8.
# H405 multi line docstring summary not separated with an empty line
show-source = True show-source = True
ignore = E123,E125 ignore = E123,E125,H405
builtins = _ 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