kopia lustrzana https://github.com/OpenDroneMap/WebODM
Fixed unit tests
rodzic
79fd4cb14b
commit
7d83a6d769
|
@ -3,7 +3,7 @@ import os
|
|||
|
||||
from django.contrib.gis.db.models import GeometryField
|
||||
from django.contrib.gis.db.models.functions import Envelope
|
||||
from django.core.exceptions import ObjectDoesNotExist, SuspiciousFileOperation
|
||||
from django.core.exceptions import ObjectDoesNotExist, SuspiciousFileOperation, ValidationError
|
||||
from django.db import transaction
|
||||
from django.db.models.functions import Cast
|
||||
from django.http import HttpResponse
|
||||
|
@ -56,7 +56,7 @@ class TaskViewSet(viewsets.ViewSet):
|
|||
get_and_check_project(request, project_pk, perms)
|
||||
try:
|
||||
task = self.queryset.get(pk=pk, project=project_pk)
|
||||
except ObjectDoesNotExist:
|
||||
except (ObjectDoesNotExist, ValidationError):
|
||||
raise exceptions.NotFound()
|
||||
|
||||
task.pending_action = pending_action
|
||||
|
@ -90,7 +90,7 @@ class TaskViewSet(viewsets.ViewSet):
|
|||
get_and_check_project(request, project_pk)
|
||||
try:
|
||||
task = self.queryset.get(pk=pk, project=project_pk)
|
||||
except ObjectDoesNotExist:
|
||||
except (ObjectDoesNotExist, ValidationError):
|
||||
raise exceptions.NotFound()
|
||||
|
||||
line_num = max(0, int(request.query_params.get('line', 0)))
|
||||
|
@ -109,7 +109,7 @@ class TaskViewSet(viewsets.ViewSet):
|
|||
get_and_check_project(request, project_pk)
|
||||
try:
|
||||
task = self.queryset.get(pk=pk, project=project_pk)
|
||||
except ObjectDoesNotExist:
|
||||
except (ObjectDoesNotExist, ValidationError):
|
||||
raise exceptions.NotFound()
|
||||
|
||||
serializer = TaskSerializer(task)
|
||||
|
@ -145,7 +145,7 @@ class TaskViewSet(viewsets.ViewSet):
|
|||
get_and_check_project(request, project_pk, ('change_project', ))
|
||||
try:
|
||||
task = self.queryset.get(pk=pk, project=project_pk)
|
||||
except ObjectDoesNotExist:
|
||||
except (ObjectDoesNotExist, ValidationError):
|
||||
raise exceptions.NotFound()
|
||||
|
||||
# Check that a user has access to reassign a project
|
||||
|
@ -175,7 +175,7 @@ class TaskNestedView(APIView):
|
|||
def get_and_check_task(self, request, pk, project_pk, annotate={}):
|
||||
try:
|
||||
task = self.queryset.annotate(**annotate).get(pk=pk, project=project_pk)
|
||||
except ObjectDoesNotExist:
|
||||
except (ObjectDoesNotExist, ValidationError):
|
||||
raise exceptions.NotFound()
|
||||
|
||||
# Check for permissions, unless the task is public
|
||||
|
|
|
@ -33,7 +33,7 @@ def dump(apps, schema_editor):
|
|||
tmp_path = os.path.join(tempfile.gettempdir(), "public_task_uuids_migration.pickle")
|
||||
pickle.dump((tasks, imageuploads, task_ids), open(tmp_path, 'wb'))
|
||||
|
||||
print("Dumped tasks and imageuploads")
|
||||
if len(tasks) > 0: print("Dumped tasks and imageuploads")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
|
|
@ -40,7 +40,7 @@ def create_uuids(apps, schema_editor):
|
|||
t.new_id = task['new_id']
|
||||
t.save()
|
||||
|
||||
print("Created UUIDs")
|
||||
if len(tasks) > 0: print("Created UUIDs")
|
||||
|
||||
|
||||
def restore(apps, schema_editor):
|
||||
|
|
|
@ -439,7 +439,7 @@ class Task(models.Model):
|
|||
return {
|
||||
'tiles': [{'url': self.get_tile_json_url(t), 'type': t} for t in types],
|
||||
'meta': {
|
||||
'task': self.id,
|
||||
'task': str(self.id),
|
||||
'project': self.project.id
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,12 +101,12 @@ class TestApi(BootTestCase):
|
|||
|
||||
# Can sort
|
||||
res = client.get('/api/projects/{}/tasks/?ordering=created_at'.format(project.id))
|
||||
self.assertTrue(res.data[0]['id'] == task.id)
|
||||
self.assertTrue(res.data[1]['id'] == task2.id)
|
||||
self.assertTrue(res.data[0]['id'] == str(task.id))
|
||||
self.assertTrue(res.data[1]['id'] == str(task2.id))
|
||||
|
||||
res = client.get('/api/projects/{}/tasks/?ordering=-created_at'.format(project.id))
|
||||
self.assertTrue(res.data[0]['id'] == task2.id)
|
||||
self.assertTrue(res.data[1]['id'] == task.id)
|
||||
self.assertTrue(res.data[0]['id'] == str(task2.id))
|
||||
self.assertTrue(res.data[1]['id'] == str(task.id))
|
||||
|
||||
# Cannot list project tasks for a project we don't have access to
|
||||
res = client.get('/api/projects/{}/tasks/'.format(other_project.id))
|
||||
|
@ -119,7 +119,7 @@ class TestApi(BootTestCase):
|
|||
# Can list task details for a task belonging to a project we have access to
|
||||
res = client.get('/api/projects/{}/tasks/{}/'.format(project.id, task.id))
|
||||
self.assertEqual(res.status_code, status.HTTP_200_OK)
|
||||
self.assertTrue(res.data["id"] == task.id)
|
||||
self.assertTrue(res.data["id"] == str(task.id))
|
||||
|
||||
# images_count field exists
|
||||
self.assertTrue(res.data["images_count"] == 0)
|
||||
|
@ -155,7 +155,11 @@ class TestApi(BootTestCase):
|
|||
self.assertEqual(res.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# Cannot access task details for a task that doesn't exist
|
||||
res = client.get('/api/projects/{}/tasks/999/'.format(project.id, other_task.id))
|
||||
res = client.get('/api/projects/{}/tasks/4004d1e9-ed2c-4983-8b93-fc7577ee6d89/'.format(project.id))
|
||||
self.assertEqual(res.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# Cannot access task details for a malformed task id
|
||||
res = client.get('/api/projects/{}/tasks/0/'.format(project.id))
|
||||
self.assertEqual(res.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
# Can update a task
|
||||
|
|
|
@ -148,7 +148,7 @@ class TestApiTask(BootTransactionTestCase):
|
|||
# Should have returned the id of the newly created task
|
||||
task = Task.objects.latest('created_at')
|
||||
self.assertTrue('id' in res.data)
|
||||
self.assertTrue(task.id == res.data['id'])
|
||||
self.assertTrue(str(task.id) == res.data['id'])
|
||||
|
||||
# Two images should have been uploaded
|
||||
self.assertTrue(ImageUpload.objects.filter(task=task).count() == 2)
|
||||
|
|
16
app/urls.py
16
app/urls.py
|
@ -1,21 +1,21 @@
|
|||
from django.conf.urls import url, include
|
||||
|
||||
from .views import app as app_views, public as public_views
|
||||
from .views import private as private_views, public as public_views
|
||||
|
||||
from app.boot import boot
|
||||
from webodm import settings
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', app_views.index, name='index'),
|
||||
url(r'^welcome/$', app_views.welcome, name='welcome'),
|
||||
url(r'^dashboard/$', app_views.dashboard, name='dashboard'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', app_views.map, name='map'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/$', app_views.map, name='map'),
|
||||
url(r'^3d/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', app_views.model_display, name='model_display'),
|
||||
url(r'^$', private_views.index, name='index'),
|
||||
url(r'^welcome/$', private_views.welcome, name='welcome'),
|
||||
url(r'^dashboard/$', private_views.dashboard, name='dashboard'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', private_views.map, name='map'),
|
||||
url(r'^map/project/(?P<project_pk>[^/.]+)/$', private_views.map, name='map'),
|
||||
url(r'^3d/project/(?P<project_pk>[^/.]+)/task/(?P<task_pk>[^/.]+)/$', private_views.model_display, name='model_display'),
|
||||
|
||||
url(r'^public/map/(?P<task_public_uuid>[^/.]+)/$', public_views.map, name='public_map'),
|
||||
|
||||
url(r'^processingnode/([\d]+)/$', app_views.processing_node, name='processing_node'),
|
||||
url(r'^processingnode/([\d]+)/$', private_views.processing_node, name='processing_node'),
|
||||
|
||||
url(r'^api/', include("app.api.urls")),
|
||||
]
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
from . import app
|
||||
from . import private
|
||||
from . import public
|
||||
|
|
|
@ -83,7 +83,7 @@ def model_display(request, project_pk=None, task_pk=None):
|
|||
'title': title,
|
||||
'params': {
|
||||
'task': json.dumps({
|
||||
'id': task.id,
|
||||
'id': str(task.id),
|
||||
'project': project.id,
|
||||
'available_assets': task.available_assets
|
||||
})
|
Ładowanie…
Reference in New Issue