Fix unit tests for Django 1.9

This patch set makes manila-ui code work with Django 1.9:

- replaces deprecated django.utils.unittest with unittest
- removes {% load url from future %} lines
- replaces old-style urlpatterns with new ones

Also, since Django < 1.7 is not supported any more by upstream,
this patch removes Django 1.4 from tests and replaces it with
Django 1.9 (while it's not in upstream yet) and Django 1.10.

Change-Id: I28f72ba799aeb2f583db00515dceef41c68170af
Closes-Bug: #1598169
This commit is contained in:
Tatiana Ovchinnikova
2016-07-01 17:47:37 +03:00
parent 9531002200
commit 62f2f5a776
17 changed files with 19 additions and 32 deletions

View File

@@ -1,5 +1,4 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<h3>{% trans "Share Instance Overview" %}</h3>
<div class="detail">

View File

@@ -1,5 +1,4 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<h3>{% trans "Share Server Overview" %}</h3>
<div class="detail">

View File

@@ -1,6 +1,5 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %}
{% block form_action %}{% url 'horizon:admin:shares:manage_share_type_access' share_type.id %}{% endblock %}

View File

@@ -1,5 +1,4 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<h3>{% trans "Snapshot Overview" %}</h3>

View File

@@ -10,13 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa
from manila_ui.dashboards.admin.shares import views
urlpatterns = patterns(
'',
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P<share_id>[^/]+)/$', views.DetailView.as_view(), name='detail'),
url(r'^snapshots/(?P<snapshot_id>[^/]+)$',
@@ -49,4 +47,4 @@ urlpatterns = patterns(
url(r'^manage$', views.ManageShareView.as_view(), name='manage'),
url(r'^unmanage/(?P<share_id>[^/]+)$', views.UnmanageShareView.as_view(),
name='unmanage'),
)
]

View File

@@ -1,6 +1,5 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %}
{% block form_action %}{% url 'horizon:project:shares:add_security_service' share_network.id %}{% endblock %}

View File

@@ -1,5 +1,4 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<h3>{% trans "Security Service Overview" %}</h3>
<div class="detail">

View File

@@ -1,5 +1,4 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<h3>{% trans "Share Network Overview" %}</h3>
<div class="detail">

View File

@@ -1,6 +1,5 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %}
{% block form_action %}{% url 'horizon:project:shares:update_share_network' share_network.id %}{% endblock %}

View File

@@ -1,6 +1,5 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %}
{% block form_action %}{% url 'horizon:project:shares:add_security_service' share_network.id %}{% endblock %}

View File

@@ -1,5 +1,4 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<h3>{% trans "Share Overview" %}</h3>
<div class="detail">

View File

@@ -1,6 +1,5 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}{% endblock %}
{% block form_action %}{% url 'horizon:project:shares:update_metadata' share.id %}{% endblock %}

View File

@@ -1,5 +1,4 @@
{% load i18n sizeformat parse_date %}
{% load url from future %}
<h3>{% trans "Snapshot Overview" %}</h3>
<div class="detail">

View File

@@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.conf.urls import patterns # noqa
from django.conf.urls import url # noqa
from manila_ui.dashboards.project.shares.security_services \
@@ -26,8 +25,7 @@ from manila_ui.dashboards.project.shares.snapshots\
from manila_ui.dashboards.project.shares import views
urlpatterns = patterns(
'openstack_dashboard.dashboards.project.shares.views',
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^\?tab=share_tabs__snapshots_tab$',
views.IndexView.as_view(),
@@ -78,4 +76,4 @@ urlpatterns = patterns(
url(r'^(?P<share_id>[^/]+)/extend/$',
shares_views.ExtendView.as_view(),
name='extend'),
)
]

View File

@@ -11,10 +11,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
from django.utils import unittest
import mock
import os
import unittest
from manila_ui import api
from manila_ui.tests.test_data import utils

View File

@@ -14,7 +14,6 @@
from django.conf import urls
import openstack_dashboard.urls
urlpatterns = urls.patterns(
'',
urlpatterns = [
urls.url(r'', urls.include(openstack_dashboard.urls))
)
]

17
tox.ini
View File

@@ -1,6 +1,6 @@
[tox]
minversion = 1.6
envlist = py27,pep8,py27dj14
envlist = py27,pep8,py27dj19
skipsdist = True
[testenv]
@@ -21,11 +21,6 @@ commands = flake8
[testenv:venv]
commands = {posargs}
[testenv:py27dj14]
basepython = python2.7
commands = pip install django>=1.4,<1.5
/bin/bash run_tests.sh -N --no-pep8 {posargs}
[testenv:py27dj17]
basepython = python2.7
commands = pip install django>=1.7,<1.8
@@ -37,6 +32,16 @@ basepython = python2.7
commands = pip install django>=1.8,<1.9
/bin/bash run_tests.sh -N --no-pep8 {posargs}
[testenv:py27dj19]
basepython = python2.7
commands = pip install django>=1.9,<1.10
/bin/bash run_tests.sh -N --no-pep8 {posargs}
[testenv:py27dj110]
basepython = python2.7
commands = pip install django<1.11 --pre --upgrade
/bin/bash run_tests.sh -N --no-pep8 {posargs}
[testenv:cover]
commands = {toxinidir}/tools/cover.sh {posargs}