-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f037c9c
commit cd5008f
Showing
2 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# -*- coding: utf-8 -*- | ||
####### | ||
# actinia-core - an open source REST API for scalable, distributed, high | ||
# performance processing of geographical data that uses GRASS GIS for | ||
# computational tasks. For details, see https://actinia.mundialis.de/ | ||
# | ||
# Copyright (c) 2016-2018 Sören Gebbert and mundialis GmbH & Co. KG | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
####### | ||
|
||
""" | ||
Tests: Import raster with pixellimit check | ||
""" | ||
import unittest | ||
from flask.json import dumps as json_dumps | ||
|
||
try: | ||
from .test_resource_base import ( | ||
ActiniaResourceTestCaseBase, | ||
URL_PREFIX, | ||
additional_external_data, | ||
) | ||
except Exception: | ||
from test_resource_base import ( | ||
ActiniaResourceTestCaseBase, | ||
URL_PREFIX, | ||
additional_external_data, | ||
) | ||
|
||
__license__ = "GPLv3" | ||
__author__ = "Lina Krisztian" | ||
__copyright__ = "Copyright 2016-2021, mundialis GmbH & Co. KG" | ||
__maintainer__ = "mundialis GmbH & Co. KG" | ||
|
||
|
||
class ImportRasterLayerPixellimitTestCase(ActiniaResourceTestCaseBase): | ||
location = "nc_spm_08" | ||
tmp_mapset = "mapset_rasterimport_pixellimit" | ||
endpoint = f"/locations/{location}/mapsets/{tmp_mapset}/processing_async" | ||
rimport_inp = "elevation" | ||
# import resolution with which the process should fail: | ||
rimport_res_fail = 0.1 | ||
|
||
def setUp(self): | ||
# create new temp mapset | ||
super(ImportRasterLayerPixellimitTestCase, self).setUp() | ||
self.create_new_mapset(self.tmp_mapset, location_name=self.location) | ||
|
||
def tearDown(self): | ||
# delete mapset | ||
self.delete_mapset(self.tmp_mapset, location_name=self.location) | ||
super(ImportRasterLayerPixellimitTestCase, self).tearDown() | ||
|
||
def test_pixellimit_not_reached(self): | ||
""" | ||
Test import of raster, for which pixellimit is not reached | ||
""" | ||
raster_url = additional_external_data[self.rimport_inp] | ||
raster = self.rimport_inp | ||
process_chain = { | ||
"version": 1, | ||
"list": [ | ||
{ | ||
"id": "1", | ||
"module": "r.import", | ||
"inputs": [ | ||
{ | ||
"param": "input", | ||
"value": raster_url, | ||
}, | ||
{ | ||
"param": "output", | ||
"value": raster, | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
rv = self.server.post( | ||
URL_PREFIX + self.endpoint, | ||
headers=self.admin_auth_header, | ||
data=json_dumps(process_chain), | ||
content_type="application/json", | ||
) | ||
# Import should succeed | ||
self.waitAsyncStatusAssertHTTP( | ||
rv, | ||
headers=self.admin_auth_header, | ||
http_status=200, | ||
status="finished", | ||
) | ||
|
||
def test_pixellimit_reached(self): | ||
""" | ||
Test import of raster, for which pixellimit is reached | ||
""" | ||
raster_url = additional_external_data[self.rimport_inp] | ||
raster = self.rimport_inp | ||
process_chain = { | ||
"version": 1, | ||
"list": [ | ||
{ | ||
"id": "1", | ||
"module": "r.import", | ||
"inputs": [ | ||
{ | ||
"param": "input", | ||
"value": raster_url, | ||
}, | ||
{ | ||
"param": "output", | ||
"value": raster, | ||
}, | ||
{ | ||
"param": "resolution", | ||
"value": "value", | ||
}, | ||
{ | ||
"param": "resolution_value", | ||
"value": f"{self.rimport_res_fail}", | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
rv = self.server.post( | ||
URL_PREFIX + self.endpoint, | ||
headers=self.admin_auth_header, | ||
data=json_dumps(process_chain), | ||
content_type="application/json", | ||
) | ||
# Import should fail (due too high resolution) | ||
self.waitAsyncStatusAssertHTTP( | ||
rv, | ||
headers=self.admin_auth_header, | ||
http_status=400, | ||
status="error", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters