TT#43813 fix RemovedInDjango20Warning issues

This will help us when jumping to Django 2+

> RemovedInDjango20Warning: Importing from django.core.urlresolvers is deprecated in favor of django.urls.

Change-Id: I13c3e1e8aea93aa48d1f7997eb6daae3b7dcfecc
changes/92/38692/1
Victor Seva 6 years ago
parent a382ec71f0
commit 69557f8e16

@ -1,41 +1,48 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com # Copyright (C) 2017 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free # under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) # Software Foundation, either version 3 of the License, or (at your option)
# any later version. # any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT # This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
#
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from django.urls import reverse
from mock import patch
from rest_framework import status from rest_framework import status
from rest_framework.test import APITestCase from rest_framework.test import APITestCase
from release_dashboard import models from release_dashboard import models
from mock import patch
class TestDockerRest(APITestCase): class TestDockerRest(APITestCase):
fixtures = ['test_model_fixtures', ] fixtures = [
"test_model_fixtures",
]
@patch('release_dashboard.utils.docker.delete_docker_info') @patch("release_dashboard.utils.docker.delete_docker_info")
def test_deletion(self, ddi): def test_deletion(self, ddi):
image_name = 'ngcp-panel-tests-rest-api-jessie' image_name = "ngcp-panel-tests-rest-api-jessie"
tag = models.DockerTag.objects.get( tag = models.DockerTag.objects.get(
name='latest', name="latest", image__name=image_name
image__name=image_name) )
response = self.client.delete( response = self.client.delete(
reverse('dockertag-detail', args=[tag.pk]), format='json') reverse("dockertag-detail", args=[tag.pk]), format="json"
)
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
self.assertFalse( self.assertFalse(
models.DockerTag.objects.filter( models.DockerTag.objects.filter(
name='latest', name="latest", image__name=image_name
image__name=image_name).exists()) ).exists()
ddi.assert_called_once_with(settings.DOCKER_REGISTRY_URL.format( )
'%s/manifests/%s' % (image_name, tag.reference))) ddi.assert_called_once_with(
settings.DOCKER_REGISTRY_URL.format(
"%s/manifests/%s" % (image_name, tag.reference)
)
)

@ -1,38 +1,39 @@
# Copyright (C) 2015 The Sipwise Team - http://sipwise.com # Copyright (C) 2015 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it # This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free # under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) # Software Foundation, either version 3 of the License, or (at your option)
# any later version. # any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT # This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
#
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
from django.urls import reverse
from django.core.urlresolvers import reverse
from rest_framework import status from rest_framework import status
from rest_framework.test import APITestCase from rest_framework.test import APITestCase
from repoapi.test.base import BaseTest from repoapi.test.base import BaseTest
class TestRest(BaseTest, APITestCase): class TestRest(BaseTest, APITestCase):
def setUp(self): def setUp(self):
super(TestRest, self).setUp() super(TestRest, self).setUp()
self.url = dict() self.url = dict()
self.url['jbi'] = reverse('jenkinsbuildinfo-list') self.url["jbi"] = reverse("jenkinsbuildinfo-list")
def test_jbi_creation(self): def test_jbi_creation(self):
data = {"url": "http://127.0.0.1:8000/jenkinsbuildinfo/1/", data = {
"projectname": "fake", "url": "http://127.0.0.1:8000/jenkinsbuildinfo/1/",
"jobname": "fake-get-code", "projectname": "fake",
"buildnumber": 1, "jobname": "fake-get-code",
"result": "OK", "buildnumber": 1,
"job_url": "http://fake.org/gogo", } "result": "OK",
"job_url": "http://fake.org/gogo",
}
data_all = { data_all = {
"url": "http://testserver/jenkinsbuildinfo/1/", "url": "http://testserver/jenkinsbuildinfo/1/",
"tag": None, "tag": None,
@ -51,9 +52,9 @@ class TestRest(BaseTest, APITestCase):
"param_distribution": None, "param_distribution": None,
"param_ppa": None, "param_ppa": None,
"repo_name": None, "repo_name": None,
"git_commit_msg": None "git_commit_msg": None,
} }
response = self.client.post(self.url['jbi'], data, format='json') response = self.client.post(self.url["jbi"], data, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.status_code, status.HTTP_201_CREATED)
data_all['date'] = response.data['date'] data_all["date"] = response.data["date"]
self.assertEqual(response.data, data_all) self.assertEqual(response.data, data_all)

Loading…
Cancel
Save