Fixed unit tests

pull/746/head
Piero Toffanin 2019-12-02 14:11:08 -05:00
rodzic 90b5a9ce91
commit 2bbcefa77a
2 zmienionych plików z 8 dodań i 24 usunięć

Wyświetl plik

@ -170,8 +170,6 @@ class TaskViewSet(viewsets.ViewSet):
except (ObjectDoesNotExist, ValidationError):
raise exceptions.NotFound()
# TODO: check at least two images are present
task.partial = False
task.images_count = models.ImageUpload.objects.filter(task=task).count()
@ -286,20 +284,6 @@ class TaskNestedView(APIView):
return task
# class TaskTiles(TaskNestedView):
# def get(self, request, pk=None, project_pk=None, tile_type="", z="", x="", y=""):
# """
# Get a tile image
# """
# task = self.get_and_check_task(request, pk)
# tile_path = task.get_tile_path(tile_type, z, x, y)
# if os.path.isfile(tile_path):
# tile = open(tile_path, "rb")
# return HttpResponse(FileWrapper(tile), content_type="image/png")
# else:
# raise exceptions.NotFound()
def download_file_response(request, filePath, content_disposition):
filename = os.path.basename(filePath)
filesize = os.stat(filePath).st_size

Wyświetl plik

@ -359,7 +359,7 @@ class TestApiTask(BootTransactionTestCase):
# Can access individual tiles
for tile_type in tile_types:
res = client.get("/api/projects/{}/tasks/{}/{}/tiles/17/32042/46185.png".format(project.id, task.id, tile_type))
self.assertEqual(res.status_code == status.HTTP_200_OK)
self.assertEqual(res.status_code, status.HTTP_200_OK)
# Another user does not have access to the resources
other_client = APIClient()
@ -368,13 +368,13 @@ class TestApiTask(BootTransactionTestCase):
def accessResources(expectedStatus):
for tile_type in tile_types:
res = other_client.get("/api/projects/{}/tasks/{}/{}/tiles.json".format(project.id, task.id, tile_type))
self.assertTrue(res.status_code == expectedStatus)
self.assertEqual(res.status_code, expectedStatus)
res = other_client.get("/api/projects/{}/tasks/{}/{}/tiles/16/16020/42443.png".format(project.id, task.id, tile_type))
self.assertTrue(res.status_code == expectedStatus)
res = other_client.get("/api/projects/{}/tasks/{}/{}/tiles/17/32042/46185.png".format(project.id, task.id, tile_type))
self.assertEqual(res.status_code, expectedStatus)
res = other_client.get("/api/projects/{}/tasks/{}/".format(project.id, task.id))
self.assertTrue(res.status_code == expectedStatus)
self.assertEqual(res.status_code, expectedStatus)
accessResources(status.HTTP_404_NOT_FOUND)
@ -576,11 +576,11 @@ class TestApiTask(BootTransactionTestCase):
# Can access only tiles of available assets
res = client.get("/api/projects/{}/tasks/{}/dsm/tiles.json".format(project.id, task.id))
self.assertTrue(res.status_code == status.HTTP_200_OK)
self.assertEqual(res.status_code, status.HTTP_200_OK)
res = client.get("/api/projects/{}/tasks/{}/dtm/tiles.json".format(project.id, task.id))
self.assertTrue(res.status_code == status.HTTP_200_OK)
self.assertEqual(res.status_code, status.HTTP_200_OK)
res = client.get("/api/projects/{}/tasks/{}/orthophoto/tiles.json".format(project.id, task.id))
self.assertTrue(res.status_code == status.HTTP_400_BAD_REQUEST)
self.assertEqual(res.status_code, status.HTTP_404_NOT_FOUND)
# Available assets should be missing orthophoto.tif type
# but others such as textured_model.zip should be available