From 86e43b9040069f0f8914bf3049e34daaecf5c2f1 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sun, 26 May 2019 11:40:05 -0400 Subject: [PATCH] Unit test fixes due to NodeODM update --- app/models/task.py | 1 - app/tests/test_api_task.py | 2 +- nodeodm/external/NodeODM | 2 +- nodeodm/models.py | 11 ++++++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/task.py b/app/models/task.py index 877c6576..6a617a1a 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -133,7 +133,6 @@ class Task(models.Model): ASSETS_MAP = { 'all.zip': 'all.zip', 'orthophoto.tif': os.path.join('odm_orthophoto', 'odm_orthophoto.tif'), - 'orthophoto.png': os.path.join('odm_orthophoto', 'odm_orthophoto.png'), 'orthophoto.mbtiles': os.path.join('odm_orthophoto', 'odm_orthophoto.mbtiles'), 'georeferenced_model.las': os.path.join('odm_georeferencing', 'odm_georeferenced_model.las'), 'georeferenced_model.laz': os.path.join('odm_georeferencing', 'odm_georeferenced_model.laz'), diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index 3474da57..f7c1723f 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -324,7 +324,7 @@ class TestApiTask(BootTransactionTestCase): # Can download assets for asset in list(task.ASSETS_MAP.keys()): res = client.get("/api/projects/{}/tasks/{}/download/{}".format(project.id, task.id, asset)) - self.assertTrue(res.status_code == status.HTTP_200_OK) + self.assertEqual(res.status_code, status.HTTP_200_OK) # We can stream downloads res = client.get("/api/projects/{}/tasks/{}/download/{}?_force_stream=1".format(project.id, task.id, list(task.ASSETS_MAP.keys())[0])) diff --git a/nodeodm/external/NodeODM b/nodeodm/external/NodeODM index 2779f733..2a5d73ae 160000 --- a/nodeodm/external/NodeODM +++ b/nodeodm/external/NodeODM @@ -1 +1 @@ -Subproject commit 2779f7337ef19aa9efbf44576a04887dd5a18762 +Subproject commit 2a5d73ae2dfc89fc69f24095baebe31f0f0ac340 diff --git a/nodeodm/models.py b/nodeodm/models.py index 82c65367..b98408e9 100644 --- a/nodeodm/models.py +++ b/nodeodm/models.py @@ -6,6 +6,7 @@ from django.utils import timezone from django.dispatch import receiver from guardian.models import GroupObjectPermissionBase from guardian.models import UserObjectPermissionBase +from webodm import settings import json from pyodm import Node @@ -115,7 +116,15 @@ class ProcessingNode(models.Model): opts = self.options_list_to_dict(options) - task = api_client.create_task(images, opts, name, progress_callback) + if not settings.TESTING: + task = api_client.create_task(images, opts, name, progress_callback) + else: + # The create_task function uses multi-threaded parallel uploads + # but Django tests cannot cope with DB updates from different threads + # (and progress_callback often updates the DB). So during testing + # we use the fallback function equivalent which is single-threaded + task = api_client.create_task_fallback(images, opts, name, progress_callback) + return task.uuid def get_task_info(self, uuid, with_output=None):