Fix crashing test

This commit is contained in:
Carl van Tonder 2018-09-22 22:25:04 -04:00
parent ff445e166d
commit ab57602a5f
3 changed files with 10 additions and 4 deletions

View File

@ -48,7 +48,7 @@ class FileTests(TestCase):
login = self.login() login = self.login()
with open('apps/map/static/map/ojuso-logo-white.png', 'rb') as fp: 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 'file': fp
}) })
@ -56,7 +56,7 @@ class FileTests(TestCase):
self.assertIsInstance(data['id'], int) self.assertIsInstance(data['id'], int)
self.assertEqual(data['is_valid'], True) 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'] 'pk': data['id']
})) }))

View File

@ -1,11 +1,13 @@
from django.conf.urls import url from django.conf.urls import url
from .views import FileUploadView, FileDeleteView, ImageFileUploadView from .views import (FileUploadView, FileDeleteView, ImageFileUploadView,
ImageFileDeleteView)
app_name = 'files' app_name = 'files'
urlpatterns = [ urlpatterns = [
url(r'^upload/$', FileUploadView.as_view(), name='upload'), 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<pk>\d+)/$', FileDeleteView.as_view(), name='delete'), url(r'^delete/(?P<pk>\d+)/$', FileDeleteView.as_view(), name='delete'),
url(r'^delete/image/(?P<pk>\d+)/$', ImageFileDeleteView.as_view(), name='delete_image'),
] ]

View File

@ -50,3 +50,7 @@ class FileDeleteView(LoginRequiredMixin, DetailView):
return JsonResponse({ return JsonResponse({
'success': True 'success': True
}) })
class ImageFileDeleteView(FileDeleteView):
model = ImageFile