From ab57602a5f8ee4cb91d2b44ff823df9cb036c818 Mon Sep 17 00:00:00 2001 From: Carl van Tonder Date: Sat, 22 Sep 2018 22:25:04 -0400 Subject: [PATCH 1/2] Fix crashing test --- apps/files/tests.py | 4 ++-- apps/files/urls.py | 6 ++++-- apps/files/views.py | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/files/tests.py b/apps/files/tests.py index 22812e8..edd8457 100644 --- a/apps/files/tests.py +++ b/apps/files/tests.py @@ -48,7 +48,7 @@ class FileTests(TestCase): login = self.login() with open('apps/map/static/map/ojuso-logo-white.png', 'rb') as fp: - response = self.client.post(reverse('files:upload'), { + response = self.client.post(reverse('files:upload_image'), { 'file': fp }) @@ -56,7 +56,7 @@ class FileTests(TestCase): self.assertIsInstance(data['id'], int) self.assertEqual(data['is_valid'], True) - response = self.client.post(reverse('files:delete', kwargs={ + response = self.client.post(reverse('files:delete_image', kwargs={ 'pk': data['id'] })) diff --git a/apps/files/urls.py b/apps/files/urls.py index aeb0607..c78b6ec 100644 --- a/apps/files/urls.py +++ b/apps/files/urls.py @@ -1,11 +1,13 @@ from django.conf.urls import url -from .views import FileUploadView, FileDeleteView, ImageFileUploadView +from .views import (FileUploadView, FileDeleteView, ImageFileUploadView, + ImageFileDeleteView) app_name = 'files' urlpatterns = [ url(r'^upload/$', FileUploadView.as_view(), name='upload'), - url(r'^upload/image/$', ImageFileUploadView.as_view(), name='upload'), + url(r'^upload/image/$', ImageFileUploadView.as_view(), name='upload_image'), url(r'^delete/(?P\d+)/$', FileDeleteView.as_view(), name='delete'), + url(r'^delete/image/(?P\d+)/$', ImageFileDeleteView.as_view(), name='delete_image'), ] diff --git a/apps/files/views.py b/apps/files/views.py index 83f0e43..8f557ad 100644 --- a/apps/files/views.py +++ b/apps/files/views.py @@ -50,3 +50,7 @@ class FileDeleteView(LoginRequiredMixin, DetailView): return JsonResponse({ 'success': True }) + + +class ImageFileDeleteView(FileDeleteView): + model = ImageFile From af9f522befc959799b13b8f4ddb23cad3a6324ad Mon Sep 17 00:00:00 2001 From: Carl van Tonder Date: Sat, 22 Sep 2018 22:25:22 -0400 Subject: [PATCH 2/2] Fix test failure --- apps/map/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/map/tests.py b/apps/map/tests.py index ffcb281..7c31f7e 100644 --- a/apps/map/tests.py +++ b/apps/map/tests.py @@ -96,7 +96,7 @@ class CaseStudyTests(TestCase): def test_get_renewable_generation_detail_with_wind(self): """get_renewable_generation_detail() should return the description prefixed with 'wind power'""" case_study = CaseStudy(generation_technology='SSWE') - self.assertEqual(case_study.get_renewable_generation_detail(), "Wind energy – Small-scale (less than 500kW)") + self.assertEqual(case_study.get_renewable_generation_detail(), "Wind energy – Small-scale (less than 500 kW)") def test_get_renewable_generation_detail_with_other(self): """get_renewable_generation_detail() should return the detail provided in .generation_technology_other"""