kopia lustrzana https://github.com/OpenDroneMap/WebODM
Add unit tests
rodzic
4897d4e52a
commit
80dcff41ca
|
@ -573,8 +573,6 @@ class ProjectListItem extends React.Component {
|
|||
render() {
|
||||
const { refreshing, data, filterTags } = this.state;
|
||||
const numTasks = data.tasks.length;
|
||||
|
||||
// const numValidTasks = data.tasks.filter(t => )
|
||||
const canEdit = this.hasPermission("change");
|
||||
const userTags = Tags.userTags(data.tags);
|
||||
let deleteWarning = _("All tasks, images and models associated with this project will be permanently deleted. Are you sure you want to continue?");
|
||||
|
|
|
@ -497,6 +497,10 @@ class TestApiTask(BootTransactionTestCase):
|
|||
self.assertEqual(metadata['algorithms'], [])
|
||||
self.assertEqual(metadata['color_maps'], [])
|
||||
|
||||
# Auto bands
|
||||
self.assertEqual(metadata['auto_bands']['filter'], '')
|
||||
self.assertEqual(metadata['auto_bands']['match'], None)
|
||||
|
||||
# Address key is removed
|
||||
self.assertFalse('address' in metadata)
|
||||
|
||||
|
@ -531,6 +535,10 @@ class TestApiTask(BootTransactionTestCase):
|
|||
self.assertTrue(len(metadata['algorithms']) > 0)
|
||||
self.assertTrue(len(metadata['color_maps']) > 0)
|
||||
|
||||
# Auto band is populated
|
||||
self.assertEqual(metadata['auto_bands']['filter'], 'RGN')
|
||||
self.assertEqual(metadata['auto_bands']['match'], False)
|
||||
|
||||
# Algorithms have valid keys
|
||||
for k in ['id', 'filters', 'expr', 'help']:
|
||||
for a in metadata['algorithms']:
|
||||
|
@ -557,6 +565,10 @@ class TestApiTask(BootTransactionTestCase):
|
|||
self.assertEqual(metadata['statistics']['1']['min'], algos['VARI']['range'][0])
|
||||
self.assertEqual(metadata['statistics']['1']['max'], algos['VARI']['range'][1])
|
||||
|
||||
# Formula can be set to auto
|
||||
res = client.get("/api/projects/{}/tasks/{}/orthophoto/metadata?formula=VARI&bands=auto".format(project.id, task.id))
|
||||
self.assertEqual(res.status_code, status.HTTP_200_OK)
|
||||
|
||||
tile_path = {
|
||||
'orthophoto': '17/32042/46185',
|
||||
'dsm': '18/64083/92370',
|
||||
|
@ -665,7 +677,9 @@ class TestApiTask(BootTransactionTestCase):
|
|||
("orthophoto", "formula=VARI&bands=RGB", status.HTTP_200_OK),
|
||||
("orthophoto", "formula=VARI&bands=invalid", status.HTTP_400_BAD_REQUEST),
|
||||
("orthophoto", "formula=invalid&bands=RGB", status.HTTP_400_BAD_REQUEST),
|
||||
|
||||
("orthophoto", "formula=NDVI&bands=auto", status.HTTP_200_OK),
|
||||
("orthophoto", "formula=NDVI&bands=auto", status.HTTP_200_OK),
|
||||
|
||||
("orthophoto", "formula=NDVI&bands=RGN&color_map=rdylgn&rescale=-1,1", status.HTTP_200_OK),
|
||||
("orthophoto", "formula=NDVI&bands=RGN&color_map=rdylgn&rescale=1,-1", status.HTTP_200_OK),
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import re
|
||||
from django.test import TestCase
|
||||
from app.api.formulas import lookup_formula, get_algorithm_list, get_camera_filters_for, algos
|
||||
from app.api.formulas import lookup_formula, get_algorithm_list, get_camera_filters_for, algos, get_auto_bands
|
||||
|
||||
class TestFormulas(TestCase):
|
||||
def setUp(self):
|
||||
|
@ -48,4 +48,32 @@ class TestFormulas(TestCase):
|
|||
# Filters are less than 5 bands
|
||||
for f in i['filters']:
|
||||
bands = list(set(re.findall(pattern, f)))
|
||||
self.assertTrue(len(bands) <= 5)
|
||||
self.assertTrue(len(bands) <= 5)
|
||||
|
||||
def test_auto_bands(self):
|
||||
obands = [{'name': 'red', 'description': 'red'},
|
||||
{'name': 'green', 'description': 'green'},
|
||||
{'name': 'blue', 'description': 'blue'},
|
||||
{'name': 'gray', 'description': 'nir'},
|
||||
{'name': 'alpha', 'description': None}]
|
||||
|
||||
self.assertEqual(get_auto_bands(obands, "NDVI")[0], "RGBN")
|
||||
self.assertTrue(get_auto_bands(obands, "NDVI")[1])
|
||||
|
||||
self.assertEqual(get_auto_bands(obands, "Celsius")[0], "L")
|
||||
self.assertFalse(get_auto_bands(obands, "Celsius")[1])
|
||||
|
||||
self.assertEqual(get_auto_bands(obands, "VARI")[0], "RGBN")
|
||||
self.assertTrue(get_auto_bands(obands, "VARI")[0])
|
||||
|
||||
obands = [{'name': 'red', 'description': None},
|
||||
{'name': 'green', 'description': None},
|
||||
{'name': 'blue', 'description': None},
|
||||
{'name': 'gray', 'description': None},
|
||||
{'name': 'alpha', 'description': None}]
|
||||
|
||||
self.assertEqual(get_auto_bands(obands, "NDVI")[0], "RGN")
|
||||
self.assertFalse(get_auto_bands(obands, "NDVI")[1])
|
||||
|
||||
self.assertEqual(get_auto_bands(obands, "VARI")[0], "RGB")
|
||||
self.assertFalse(get_auto_bands(obands, "VARI")[1])
|
Ładowanie…
Reference in New Issue