Fixed unit tests, added new tests

pull/571/head
Piero Toffanin 2018-12-10 10:01:38 -05:00
rodzic 95e74a4e9c
commit 93c28a8ab9
5 zmienionych plików z 47 dodań i 20 usunięć

Wyświetl plik

@ -512,7 +512,7 @@ class TaskListItem extends React.Component {
/> : ""}
{showMemoryErrorWarning ?
<div className="task-warning"><i className="fa fa-support"></i> <span>It looks like your processing node ran out of memory. If you are using docker, make sure that your docker environment has <a href={memoryErrorLink} target="_blank">enough RAM allocated</a>. Alternatively, make sure you have enough physical RAM, reduce the number of images, make your images smaller, or reduce the max-concurrency parameter from the task's <a href="javascript:void(0);" onClick={this.startEditing}>options</a>.</span></div> : ""}
<div className="task-warning"><i className="fa fa-support"></i> <span>It looks like your processing node ran out of memory. If you are using docker, make sure that your docker environment has <a href={memoryErrorLink} target="_blank">enough RAM allocated</a>. Alternatively, make sure you have enough physical RAM, reduce the number of images, make your images smaller, or reduce the max-concurrency parameter from the task's <a href="javascript:void(0);" onClick={this.startEditing}>options</a>. You can also try to use a <a href="https://www.opendronemap.org/webodm/lightning/" target="_blank">cloud processing node</a>.</span></div> : ""}
{showTaskWarning ?
<div className="task-warning"><i className="fa fa-support"></i> <span dangerouslySetInnerHTML={{__html: this.state.friendlyTaskError}} /></div> : ""}

Wyświetl plik

@ -350,6 +350,9 @@ class TestApi(BootTestCase):
# Should be set to false
self.assertFalse(res.data['online'])
# Verify max images field
self.assertTrue("max_images" in res.data)
# Cannot delete a processing node as normal user
res = client.delete('/api/processingnodes/{}/'.format(pnode.id))
self.assertTrue(res.status_code, status.HTTP_403_FORBIDDEN)

Wyświetl plik

@ -127,6 +127,7 @@ class TestApiTask(BootTransactionTestCase):
with Image.open(multiple_param_task.task_path("tiny_drone_image.jpg")) as im:
self.assertTrue(im.size == img1.size)
multiple_param_task.delete()
# Normal case with images[], GCP, name and processing node parameter and resize_to option
gcp = open("app/fixtures/gcp.txt", 'r')
@ -161,6 +162,14 @@ class TestApiTask(BootTransactionTestCase):
self.assertTrue(float(px) == 8.0) # Didn't change
self.assertTrue(float(py) == 8.0) # Didn't change
# Resize progress is 100%
self.assertEqual(resized_task.resize_progress, 1.0)
# Upload progress is 100%
self.assertEqual(resized_task.upload_progress, 1.0)
resized_task.delete()
# Case with malformed GCP file option
with open("app/fixtures/gcp_malformed.txt", 'r') as malformed_gcp:
res = client.post("/api/projects/{}/tasks/".format(project.id), {
@ -181,6 +190,8 @@ class TestApiTask(BootTransactionTestCase):
image1.seek(0)
image2.seek(0)
malformed_gcp_task.delete()
# Cannot create a task with images[], name, but invalid processing node parameter
res = client.post("/api/projects/{}/tasks/".format(project.id), {
@ -206,12 +217,18 @@ class TestApiTask(BootTransactionTestCase):
self.assertTrue('id' in res.data)
self.assertTrue(str(task.id) == res.data['id'])
# Progress is at 0%
self.assertEqual(task.running_progress, 0.0)
# Two images should have been uploaded
self.assertTrue(ImageUpload.objects.filter(task=task).count() == 2)
# Can_rerun_from should be an empty list
self.assertTrue(len(res.data['can_rerun_from']) == 0)
# processing_node_name should be null
self.assertTrue(res.data['processing_node_name'] is None)
# No processing node is set
self.assertTrue(task.processing_node is None)
@ -262,9 +279,26 @@ class TestApiTask(BootTransactionTestCase):
# (during tests this is sync)
# Processing should have started and a UUID is assigned
task.refresh_from_db()
self.assertTrue(task.status in [status_codes.RUNNING, status_codes.COMPLETED]) # Sometimes the task finishes and we can't test for RUNNING state
self.assertTrue(len(task.uuid) > 0)
# Calling process pending tasks should finish the process
# and invoke the plugins completed signal
with catch_signal(task_completed) as handler:
task.refresh_from_db()
self.assertTrue(task.status in [status_codes.RUNNING,
status_codes.COMPLETED]) # Sometimes the task finishes and we can't test for RUNNING state
self.assertTrue(len(task.uuid) > 0)
worker.tasks.process_pending_tasks()
time.sleep(DELAY)
task.refresh_from_db()
self.assertTrue(task.status == status_codes.COMPLETED)
# Progress is 100%
self.assertTrue(task.running_progress == 1.0)
handler.assert_called_with(
sender=Task,
task_id=task.id,
signal=task_completed,
)
# Processing node should have a "rerun_from" option
pnode_rerun_from_opts = list(filter(lambda d: 'name' in d and d['name'] == 'rerun-from', pnode.available_options))[0]
@ -277,20 +311,8 @@ class TestApiTask(BootTransactionTestCase):
self.assertTrue(res.status_code == status.HTTP_200_OK)
self.assertTrue(pnode_rerun_from_opts['domain'] == res.data['can_rerun_from'])
time.sleep(DELAY)
# Calling process pending tasks should finish the process
# and invoke the plugins completed signal
with catch_signal(task_completed) as handler:
worker.tasks.process_pending_tasks()
task.refresh_from_db()
self.assertTrue(task.status == status_codes.COMPLETED)
handler.assert_called_with(
sender=Task,
task_id=task.id,
signal=task_completed,
)
# processing_node_name should be the name of the pnode
self.assertEqual(res.data['processing_node_name'], str(pnode))
# Can download assets
for asset in list(task.ASSETS_MAP.keys()):

Wyświetl plik

@ -45,6 +45,7 @@ class TestClientApi(TestCase):
info = self.api_client.info()
self.assertTrue(isinstance(info['version'], six.string_types), "Found version string")
self.assertTrue(isinstance(info['taskQueueCount'], int), "Found task queue count")
self.assertTrue(isinstance(info['maxImages'], int), "Found task max images")
def test_options(self):
options = self.api_client.options()
@ -58,9 +59,10 @@ class TestClientApi(TestCase):
self.assertTrue(online_node.api_version == "", "API version is not set")
self.assertTrue(online_node.update_node_info(), "Could update info")
self.assertTrue(online_node.last_refreshed != None, "Last refreshed is set")
self.assertTrue(online_node.last_refreshed is not None, "Last refreshed is set")
self.assertTrue(len(online_node.available_options) > 0, "Available options are set")
self.assertTrue(online_node.api_version != "", "API version is set")
self.assertTrue(online_node.max_images > 0, "Max images is set")
self.assertTrue(isinstance(online_node.get_available_options_json(), six.string_types), "Available options json works")
self.assertTrue(isinstance(online_node.get_available_options_json(pretty=True), six.string_types), "Available options json works with pretty")

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "WebODM",
"version": "0.6.3",
"version": "0.7.0",
"description": "Open Source Drone Image Processing",
"main": "index.js",
"scripts": {