diff --git a/api_tests/craton_tests.py b/api_tests/craton_tests.py index 51fc3e0..dc831dc 100644 --- a/api_tests/craton_tests.py +++ b/api_tests/craton_tests.py @@ -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() diff --git a/craton_dashboard/api/__init__.py b/craton_dashboard/api/__init__.py index 7914d13..e69de29 100644 --- a/craton_dashboard/api/__init__.py +++ b/craton_dashboard/api/__init__.py @@ -1 +0,0 @@ -from craton_dashboard.api import craton diff --git a/craton_dashboard/api/craton.py b/craton_dashboard/api/craton.py index f18120a..a806b71 100644 --- a/craton_dashboard/api/craton.py +++ b/craton_dashboard/api/craton.py @@ -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 diff --git a/craton_dashboard/api/rest/__init__.py b/craton_dashboard/api/rest/__init__.py index 1389bfb..e69de29 100644 --- a/craton_dashboard/api/rest/__init__.py +++ b/craton_dashboard/api/rest/__init__.py @@ -1 +0,0 @@ -from craton_dashboard.api.rest import craton diff --git a/craton_dashboard/api/rest/craton.py b/craton_dashboard/api/rest/craton.py index 3985f0f..ba77a9b 100644 --- a/craton_dashboard/api/rest/craton.py +++ b/craton_dashboard/api/rest/craton.py @@ -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) - diff --git a/craton_dashboard/content/fleet_management/__init__.py b/craton_dashboard/content/fleet_management/__init__.py index b3be5c1..e69de29 100644 --- a/craton_dashboard/content/fleet_management/__init__.py +++ b/craton_dashboard/content/fleet_management/__init__.py @@ -1 +0,0 @@ -from craton_dashboard.api import rest diff --git a/craton_dashboard/content/fleet_management/inventory/panel.py b/craton_dashboard/content/fleet_management/inventory/panel.py index 1dab749..8df99e6 100644 --- a/craton_dashboard/content/fleet_management/inventory/panel.py +++ b/craton_dashboard/content/fleet_management/inventory/panel.py @@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _ import horizon + class Inventory(horizon.Panel): name = _('Inventory') slug = 'fleet.inventory' diff --git a/craton_dashboard/content/fleet_management/inventory/urls.py b/craton_dashboard/content/fleet_management/inventory/urls.py index d0e6905..ab9e8fe 100644 --- a/craton_dashboard/content/fleet_management/inventory/urls.py +++ b/craton_dashboard/content/fleet_management/inventory/urls.py @@ -5,4 +5,3 @@ from craton_dashboard.content.fleet_management.inventory import views urlpatterns = [ url(r'^$', views.IndexView.as_view(), name='index'), ] - diff --git a/craton_dashboard/content/fleet_management/inventory/views.py b/craton_dashboard/content/fleet_management/inventory/views.py index e7ede43..1756371 100644 --- a/craton_dashboard/content/fleet_management/inventory/views.py +++ b/craton_dashboard/content/fleet_management/inventory/views.py @@ -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') - diff --git a/craton_dashboard/content/fleet_management/taskflows/panel.py b/craton_dashboard/content/fleet_management/taskflows/panel.py index 5e3af04..e581267 100644 --- a/craton_dashboard/content/fleet_management/taskflows/panel.py +++ b/craton_dashboard/content/fleet_management/taskflows/panel.py @@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _ import horizon + class Taskflows(horizon.Panel): name = _('Taskflows') slug = 'fleet.taskflows' diff --git a/craton_dashboard/content/fleet_management/taskflows/urls.py b/craton_dashboard/content/fleet_management/taskflows/urls.py index a10b4cc..0ae2891 100644 --- a/craton_dashboard/content/fleet_management/taskflows/urls.py +++ b/craton_dashboard/content/fleet_management/taskflows/urls.py @@ -5,4 +5,3 @@ from craton_dashboard.content.fleet_management.taskflows import views urlpatterns = [ url(r'^$', views.IndexView.as_view(), name='index'), ] - diff --git a/craton_dashboard/content/fleet_management/taskflows/views.py b/craton_dashboard/content/fleet_management/taskflows/views.py index 57a05f2..18cac56 100644 --- a/craton_dashboard/content/fleet_management/taskflows/views.py +++ b/craton_dashboard/content/fleet_management/taskflows/views.py @@ -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') - diff --git a/craton_dashboard/enabled/_1720_fleet_taskflows_panel.py b/craton_dashboard/enabled/_1720_fleet_taskflows_panel.py index 0aa6a3d..8f8d977 100644 --- a/craton_dashboard/enabled/_1720_fleet_taskflows_panel.py +++ b/craton_dashboard/enabled/_1720_fleet_taskflows_panel.py @@ -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' diff --git a/craton_dashboard/enabled/_1730_fleet_inventory_panel.py b/craton_dashboard/enabled/_1730_fleet_inventory_panel.py index c313a73..3dcab86 100644 --- a/craton_dashboard/enabled/_1730_fleet_inventory_panel.py +++ b/craton_dashboard/enabled/_1730_fleet_inventory_panel.py @@ -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') - diff --git a/craton_dashboard/test/helpers.py b/craton_dashboard/test/helpers.py index b185498..d3fdddb 100644 --- a/craton_dashboard/test/helpers.py +++ b/craton_dashboard/test/helpers.py @@ -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() diff --git a/craton_dashboard/test/settings.py b/craton_dashboard/test/settings.py index f9c2b98..8495d24 100644 --- a/craton_dashboard/test/settings.py +++ b/craton_dashboard/test/settings.py @@ -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') diff --git a/craton_dashboard/test/test_data/craton_data.py b/craton_dashboard/test/test_data/craton_data.py index 6898311..ab2e803 100644 --- a/craton_dashboard/test/test_data/craton_data.py +++ b/craton_dashboard/test/test_data/craton_data.py @@ -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() diff --git a/craton_dashboard/test/test_data/utils.py b/craton_dashboard/test/test_data/utils.py index e6fdb68..8496cb9 100644 --- a/craton_dashboard/test/test_data/utils.py +++ b/craton_dashboard/test/test_data/utils.py @@ -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, diff --git a/test-requirements.txt b/test-requirements.txt index 3119833..3618dfe 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tools/install_venv.py b/tools/install_venv.py index d4e5363..a4f0485 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -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(): diff --git a/tox.ini b/tox.ini index d32be0f..db04af7 100644 --- a/tox.ini +++ b/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