kopia lustrzana https://github.com/OpenDroneMap/WebODM
More resilient tests
rodzic
53943c3f69
commit
69f80b320e
|
@ -870,7 +870,7 @@ class TestApiTask(BootTransactionTestCase):
|
||||||
|
|
||||||
# Restart node-odm as to not generate orthophotos
|
# Restart node-odm as to not generate orthophotos
|
||||||
testWatch.clear()
|
testWatch.clear()
|
||||||
with start_processing_node("--test_skip_orthophotos"):
|
with start_processing_node(["--test_skip_orthophotos"]):
|
||||||
res = client.post("/api/projects/{}/tasks/".format(project.id), {
|
res = client.post("/api/projects/{}/tasks/".format(project.id), {
|
||||||
'images': [image1, image2],
|
'images': [image1, image2],
|
||||||
'name': 'test_task_no_orthophoto',
|
'name': 'test_task_no_orthophoto',
|
||||||
|
|
|
@ -16,11 +16,11 @@ from webodm import settings
|
||||||
logger = logging.getLogger('app.logger')
|
logger = logging.getLogger('app.logger')
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def start_processing_node(*args):
|
def start_processing_node(args = []):
|
||||||
current_dir = os.path.dirname(os.path.realpath(__file__))
|
current_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
node_odm = subprocess.Popen(['node', 'index.js', '--port', '11223', '--test'] + list(args), shell=False,
|
node_odm = subprocess.Popen(['node', 'index.js', '--port', '11223', '--test'] + args, shell=False,
|
||||||
cwd=os.path.join(current_dir, "..", "..", "nodeodm", "external", "NodeODM"))
|
cwd=os.path.join(current_dir, "..", "..", "nodeodm", "external", "NodeODM"))
|
||||||
time.sleep(2) # Wait for the server to launch
|
time.sleep(3) # Wait for the server to launch
|
||||||
yield node_odm
|
yield node_odm
|
||||||
node_odm.terminate()
|
node_odm.terminate()
|
||||||
time.sleep(1) # Wait for the server to stop
|
time.sleep(1) # Wait for the server to stop
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
"available_options": {},
|
"available_options": {},
|
||||||
"hostname": "localhost",
|
"hostname": "localhost",
|
||||||
"last_refreshed": null,
|
"last_refreshed": null,
|
||||||
"port": 11224,
|
"port": 11223,
|
||||||
"queue_count": 0,
|
"queue_count": 0,
|
||||||
"token": "test_token"
|
"token": "test_token"
|
||||||
},
|
},
|
||||||
|
|
336
nodeodm/tests.py
336
nodeodm/tests.py
|
@ -4,13 +4,14 @@ from datetime import timedelta, datetime
|
||||||
import requests
|
import requests
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
import subprocess, time
|
import time
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from pyodm import Node
|
from pyodm import Node
|
||||||
from pyodm.exceptions import NodeConnectionError, NodeServerError, NodeResponseError
|
from pyodm.exceptions import NodeConnectionError, NodeServerError, NodeResponseError
|
||||||
from webodm import settings
|
from webodm import settings
|
||||||
|
from app.tests.utils import start_processing_node
|
||||||
from .models import ProcessingNode
|
from .models import ProcessingNode
|
||||||
from . import status_codes
|
from . import status_codes
|
||||||
|
|
||||||
|
@ -23,14 +24,11 @@ class TestClientApi(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestClientApi, cls).setUpClass()
|
super(TestClientApi, cls).setUpClass()
|
||||||
cls.node_odm = subprocess.Popen(['node', 'index.js', '--port', '11223', '--test'], shell=False, cwd=path.join(current_dir, "external", "NodeODM"))
|
|
||||||
time.sleep(2) # Wait for the server to launch
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
super(TestClientApi, cls).tearDownClass()
|
super(TestClientApi, cls).tearDownClass()
|
||||||
cls.node_odm.terminate()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.api_client = Node("localhost", 11223)
|
self.api_client = Node("localhost", 11223)
|
||||||
|
@ -44,30 +42,33 @@ class TestClientApi(TestCase):
|
||||||
self.assertRaises(NodeConnectionError, api.options)
|
self.assertRaises(NodeConnectionError, api.options)
|
||||||
|
|
||||||
def test_info(self):
|
def test_info(self):
|
||||||
info = self.api_client.info()
|
with start_processing_node():
|
||||||
self.assertTrue(isinstance(info.version, six.string_types), "Found version string")
|
info = self.api_client.info()
|
||||||
self.assertTrue(isinstance(info.task_queue_count, int), "Found task queue count")
|
self.assertTrue(isinstance(info.version, six.string_types), "Found version string")
|
||||||
self.assertTrue(info.max_images is None, "Found task max images")
|
self.assertTrue(isinstance(info.task_queue_count, int), "Found task queue count")
|
||||||
|
self.assertTrue(info.max_images is None, "Found task max images")
|
||||||
|
|
||||||
def test_options(self):
|
def test_options(self):
|
||||||
options = self.api_client.options()
|
with start_processing_node():
|
||||||
self.assertTrue(len(options) > 0, "Found options")
|
options = self.api_client.options()
|
||||||
|
self.assertTrue(len(options) > 0, "Found options")
|
||||||
|
|
||||||
def test_online_processing_node(self):
|
def test_online_processing_node(self):
|
||||||
online_node = ProcessingNode.objects.get(pk=1)
|
with start_processing_node():
|
||||||
self.assertTrue(str(online_node) == "localhost:11223", "Formatting string works")
|
online_node = ProcessingNode.objects.get(pk=1)
|
||||||
self.assertTrue(online_node.last_refreshed == None, "Last refreshed not yet set")
|
self.assertTrue(str(online_node) == "localhost:11223", "Formatting string works")
|
||||||
self.assertTrue(len(online_node.available_options) == 0, "Available options not yet set")
|
self.assertTrue(online_node.last_refreshed == None, "Last refreshed not yet set")
|
||||||
self.assertTrue(online_node.api_version == "", "API version is not set")
|
self.assertTrue(len(online_node.available_options) == 0, "Available options not yet set")
|
||||||
|
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.update_node_info(), "Could update info")
|
||||||
self.assertTrue(online_node.last_refreshed is not 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(len(online_node.available_options) > 0, "Available options are set")
|
||||||
self.assertTrue(online_node.api_version != "", "API version is set")
|
self.assertTrue(online_node.api_version != "", "API version is set")
|
||||||
self.assertTrue(online_node.max_images is None, "No max images limit is set")
|
self.assertTrue(online_node.max_images is None, "No max images limit 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(), 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")
|
self.assertTrue(isinstance(online_node.get_available_options_json(pretty=True), six.string_types), "Available options json works with pretty")
|
||||||
|
|
||||||
|
|
||||||
def test_offline_processing_node(self):
|
def test_offline_processing_node(self):
|
||||||
|
@ -76,8 +77,9 @@ class TestClientApi(TestCase):
|
||||||
self.assertTrue(offline_node.api_version == "", "API version is not set")
|
self.assertTrue(offline_node.api_version == "", "API version is not set")
|
||||||
|
|
||||||
def test_auto_update_node_info(self):
|
def test_auto_update_node_info(self):
|
||||||
online_node = ProcessingNode.objects.create(hostname="localhost", port=11223)
|
with start_processing_node():
|
||||||
self.assertTrue(online_node.last_refreshed != None, "Last refreshed info is here (update_node_info() was called)")
|
online_node = ProcessingNode.objects.create(hostname="localhost", port=11223)
|
||||||
|
self.assertTrue(online_node.last_refreshed != None, "Last refreshed info is here (update_node_info() was called)")
|
||||||
|
|
||||||
def test_client_api_and_task_methods(self):
|
def test_client_api_and_task_methods(self):
|
||||||
def wait_for_status(api, uuid, status, num_retries = 10, error_description = "Failed to wait for status"):
|
def wait_for_status(api, uuid, status, num_retries = 10, error_description = "Failed to wait for status"):
|
||||||
|
@ -96,113 +98,110 @@ class TestClientApi(TestCase):
|
||||||
self.assertTrue(False, error_description)
|
self.assertTrue(False, error_description)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
api = Node("localhost", 11223)
|
with start_processing_node():
|
||||||
online_node = ProcessingNode.objects.get(pk=1)
|
api = Node("localhost", 11223)
|
||||||
|
online_node = ProcessingNode.objects.get(pk=1)
|
||||||
|
|
||||||
# Can call info(), options()
|
# Can call info(), options()
|
||||||
self.assertTrue(type(api.info().version) == str)
|
self.assertTrue(type(api.info().version) == str)
|
||||||
self.assertTrue(len(api.options()) > 0)
|
self.assertTrue(len(api.options()) > 0)
|
||||||
|
|
||||||
# Can call new_task()
|
# Can call new_task()
|
||||||
import glob
|
import glob
|
||||||
res = api.create_task(
|
res = api.create_task(
|
||||||
glob.glob("nodeodm/fixtures/test_images/*.JPG"),
|
glob.glob("nodeodm/fixtures/test_images/*.JPG"),
|
||||||
{'force-ccd': 6.16},
|
{'force-ccd': 6.16},
|
||||||
"test")
|
"test")
|
||||||
uuid = res.uuid
|
uuid = res.uuid
|
||||||
self.assertTrue(uuid != None)
|
self.assertTrue(uuid != None)
|
||||||
|
|
||||||
# Can call task_info()
|
# Can call task_info()
|
||||||
task = api.get_task(uuid)
|
task = api.get_task(uuid)
|
||||||
task_info = task.info()
|
task_info = task.info()
|
||||||
self.assertTrue(isinstance(task_info.date_created, datetime))
|
self.assertTrue(isinstance(task_info.date_created, datetime))
|
||||||
self.assertTrue(isinstance(task_info.uuid, str))
|
self.assertTrue(isinstance(task_info.uuid, str))
|
||||||
|
|
||||||
# Can download assets?
|
# Can download assets?
|
||||||
# Here we are waiting for the task to be completed
|
# Here we are waiting for the task to be completed
|
||||||
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not download assets")
|
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not download assets")
|
||||||
asset = api.get_task(uuid).download_zip(settings.MEDIA_TMP)
|
asset = api.get_task(uuid).download_zip(settings.MEDIA_TMP)
|
||||||
self.assertTrue(os.path.exists(asset))
|
self.assertTrue(os.path.exists(asset))
|
||||||
|
|
||||||
# task_output
|
# task_output
|
||||||
self.assertTrue(isinstance(api.get_task(uuid).output(0), list))
|
self.assertTrue(isinstance(api.get_task(uuid).output(0), list))
|
||||||
self.assertTrue(isinstance(online_node.get_task_console_output(uuid, 0), list))
|
self.assertTrue(isinstance(online_node.get_task_console_output(uuid, 0), list))
|
||||||
|
|
||||||
self.assertRaises(NodeResponseError, online_node.get_task_console_output, "wrong-uuid", 0)
|
self.assertRaises(NodeResponseError, online_node.get_task_console_output, "wrong-uuid", 0)
|
||||||
|
|
||||||
# Can restart task
|
# Can restart task
|
||||||
self.assertTrue(online_node.restart_task(uuid))
|
self.assertTrue(online_node.restart_task(uuid))
|
||||||
self.assertRaises(NodeResponseError, online_node.restart_task, "wrong-uuid")
|
self.assertRaises(NodeResponseError, online_node.restart_task, "wrong-uuid")
|
||||||
|
|
||||||
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not restart task")
|
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not restart task")
|
||||||
|
|
||||||
# Can restart task by passing options
|
# Can restart task by passing options
|
||||||
self.assertTrue(online_node.restart_task(uuid, [{'name': 'mesh-size', 'value': 12345},
|
self.assertTrue(online_node.restart_task(uuid, [{'name': 'mesh-size', 'value': 12345},
|
||||||
{'name': 'invalid', 'value': True}]))
|
{'name': 'invalid', 'value': True}]))
|
||||||
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not restart task with options")
|
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not restart task with options")
|
||||||
|
|
||||||
# Verify that options have been updated after restarting the task
|
# Verify that options have been updated after restarting the task
|
||||||
task_info = api.get_task(uuid).info()
|
task_info = api.get_task(uuid).info()
|
||||||
self.assertTrue(len(task_info.options) == 2) # pc-ept has been added
|
self.assertTrue(len(task_info.options) == 2) # pc-ept has been added
|
||||||
self.assertTrue(task_info.options[0]['name'] == 'mesh-size')
|
self.assertTrue(task_info.options[0]['name'] == 'mesh-size')
|
||||||
self.assertTrue(task_info.options[0]['value'] == 12345)
|
self.assertTrue(task_info.options[0]['value'] == 12345)
|
||||||
|
|
||||||
# Can cancel task (should work even if we completed the task)
|
# Can cancel task (should work even if we completed the task)
|
||||||
self.assertTrue(online_node.cancel_task(uuid))
|
self.assertTrue(online_node.cancel_task(uuid))
|
||||||
self.assertRaises(NodeResponseError, online_node.cancel_task, "wrong-uuid")
|
self.assertRaises(NodeResponseError, online_node.cancel_task, "wrong-uuid")
|
||||||
|
|
||||||
# Wait for task to be canceled
|
# Wait for task to be canceled
|
||||||
wait_for_status(api, uuid, status_codes.CANCELED, 5, "Could not remove task")
|
wait_for_status(api, uuid, status_codes.CANCELED, 5, "Could not remove task")
|
||||||
self.assertTrue(online_node.remove_task(uuid))
|
self.assertTrue(online_node.remove_task(uuid))
|
||||||
self.assertRaises(NodeResponseError, online_node.remove_task, "wrong-uuid")
|
self.assertRaises(NodeResponseError, online_node.remove_task, "wrong-uuid")
|
||||||
|
|
||||||
# Cannot delete task again
|
# Cannot delete task again
|
||||||
self.assertRaises(NodeResponseError, online_node.remove_task, uuid)
|
self.assertRaises(NodeResponseError, online_node.remove_task, uuid)
|
||||||
|
|
||||||
# Task has been deleted
|
# Task has been deleted
|
||||||
self.assertRaises(NodeResponseError, online_node.get_task_info, uuid)
|
self.assertRaises(NodeResponseError, online_node.get_task_info, uuid)
|
||||||
|
|
||||||
# Test URL building for HTTPS
|
# Test URL building for HTTPS
|
||||||
sslApi = Node("localhost", 443, 'abc')
|
sslApi = Node("localhost", 443, 'abc')
|
||||||
self.assertEqual(sslApi.url('/info'), 'https://localhost/info?token=abc')
|
self.assertEqual(sslApi.url('/info'), 'https://localhost/info?token=abc')
|
||||||
|
|
||||||
def test_find_best_available_node_and_is_online(self):
|
def test_find_best_available_node_and_is_online(self):
|
||||||
# Fixtures are all offline
|
with start_processing_node():
|
||||||
self.assertTrue(ProcessingNode.find_best_available_node() is None)
|
# Fixtures are all offline
|
||||||
|
self.assertTrue(ProcessingNode.find_best_available_node() is None)
|
||||||
|
|
||||||
# Bring one online
|
# Bring one online
|
||||||
pnode = ProcessingNode.objects.get(pk=1)
|
pnode = ProcessingNode.objects.get(pk=1)
|
||||||
self.assertFalse(pnode.is_online())
|
self.assertFalse(pnode.is_online())
|
||||||
|
|
||||||
pnode.last_refreshed = timezone.now()
|
pnode.last_refreshed = timezone.now()
|
||||||
pnode.queue_count = 2
|
pnode.queue_count = 2
|
||||||
pnode.save()
|
pnode.save()
|
||||||
|
|
||||||
self.assertTrue(pnode.is_online())
|
self.assertTrue(pnode.is_online())
|
||||||
self.assertTrue(ProcessingNode.find_best_available_node().id == pnode.id)
|
self.assertTrue(ProcessingNode.find_best_available_node().id == pnode.id)
|
||||||
|
|
||||||
# Bring another online with lower queue count
|
# Bring another online with lower queue count
|
||||||
another_pnode = ProcessingNode.objects.get(pk=2)
|
another_pnode = ProcessingNode.objects.get(pk=2)
|
||||||
another_pnode.last_refreshed = pnode.last_refreshed
|
another_pnode.last_refreshed = pnode.last_refreshed
|
||||||
another_pnode.queue_count = 1
|
another_pnode.queue_count = 1
|
||||||
another_pnode.save()
|
another_pnode.save()
|
||||||
|
|
||||||
self.assertTrue(ProcessingNode.find_best_available_node().id == another_pnode.id)
|
self.assertTrue(ProcessingNode.find_best_available_node().id == another_pnode.id)
|
||||||
|
|
||||||
# Bring it offline
|
# Bring it offline
|
||||||
another_pnode.last_refreshed -= timedelta(minutes=settings.NODE_OFFLINE_MINUTES)
|
another_pnode.last_refreshed -= timedelta(minutes=settings.NODE_OFFLINE_MINUTES)
|
||||||
another_pnode.save()
|
another_pnode.save()
|
||||||
self.assertFalse(another_pnode.is_online())
|
self.assertFalse(another_pnode.is_online())
|
||||||
|
|
||||||
# Best choice now is original processing node
|
# Best choice now is original processing node
|
||||||
self.assertTrue(ProcessingNode.find_best_available_node().id == pnode.id)
|
self.assertTrue(ProcessingNode.find_best_available_node().id == pnode.id)
|
||||||
|
|
||||||
def test_token_auth(self):
|
def test_token_auth(self):
|
||||||
node_odm = subprocess.Popen(
|
|
||||||
['node', 'index.js', '--port', '11224', '--token', 'test_token', '--test'], shell=False,
|
|
||||||
cwd=path.join(current_dir, "external", "NodeODM"))
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
def wait_for_status(api, uuid, status, num_retries=10, error_description="Failed to wait for status"):
|
def wait_for_status(api, uuid, status, num_retries=10, error_description="Failed to wait for status"):
|
||||||
retries = 0
|
retries = 0
|
||||||
while True:
|
while True:
|
||||||
|
@ -219,80 +218,79 @@ class TestClientApi(TestCase):
|
||||||
self.assertTrue(False, error_description)
|
self.assertTrue(False, error_description)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
api = Node("localhost", 11224, "test_token")
|
with start_processing_node(['--token', 'test_token']):
|
||||||
online_node = ProcessingNode.objects.get(pk=3)
|
api = Node("localhost", 11223, "test_token")
|
||||||
|
online_node = ProcessingNode.objects.get(pk=3)
|
||||||
|
|
||||||
self.assertTrue(online_node.update_node_info(), "Could update info")
|
self.assertTrue(online_node.update_node_info(), "Could update info")
|
||||||
|
|
||||||
# Cannot call info(), options() without tokens
|
# Cannot call info(), options() without tokens
|
||||||
api.token = "invalid"
|
api.token = "invalid"
|
||||||
self.assertRaises(NodeResponseError, api.info)
|
self.assertRaises(NodeResponseError, api.info)
|
||||||
self.assertRaises(NodeResponseError, api.options)
|
self.assertRaises(NodeResponseError, api.options)
|
||||||
|
|
||||||
# Cannot call create_task() without token
|
# Cannot call create_task() without token
|
||||||
import glob
|
import glob
|
||||||
self.assertRaises(NodeResponseError, api.create_task, glob.glob("nodeodm/fixtures/test_images/*.JPG"))
|
self.assertRaises(NodeResponseError, api.create_task, glob.glob("nodeodm/fixtures/test_images/*.JPG"))
|
||||||
|
|
||||||
# Can call create_task() with token
|
# Can call create_task() with token
|
||||||
api.token = "test_token"
|
api.token = "test_token"
|
||||||
res = api.create_task(
|
res = api.create_task(
|
||||||
glob.glob("nodeodm/fixtures/test_images/*.JPG"))
|
glob.glob("nodeodm/fixtures/test_images/*.JPG"))
|
||||||
uuid = res.uuid
|
uuid = res.uuid
|
||||||
self.assertTrue(uuid != None)
|
self.assertTrue(uuid != None)
|
||||||
|
|
||||||
# Can call task_info() with token
|
# Can call task_info() with token
|
||||||
task_info = api.get_task(uuid).info()
|
task_info = api.get_task(uuid).info()
|
||||||
self.assertTrue(isinstance(task_info.date_created, datetime))
|
self.assertTrue(isinstance(task_info.date_created, datetime))
|
||||||
|
|
||||||
# Cannot call task_info() without token
|
# Cannot call task_info() without token
|
||||||
api.token = "invalid"
|
api.token = "invalid"
|
||||||
try:
|
try:
|
||||||
api.get_task(uuid).info()
|
api.get_task(uuid).info()
|
||||||
except NodeResponseError as e:
|
except NodeResponseError as e:
|
||||||
self.assertTrue('token does not match' in str(e))
|
self.assertTrue('token does not match' in str(e))
|
||||||
|
|
||||||
# Here we are waiting for the task to be completed
|
# Here we are waiting for the task to be completed
|
||||||
api.token = "test_token"
|
api.token = "test_token"
|
||||||
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not download assets")
|
wait_for_status(api, uuid, status_codes.COMPLETED, 10, "Could not download assets")
|
||||||
|
|
||||||
# Cannot download assets without token
|
# Cannot download assets without token
|
||||||
api.token = "invalid"
|
api.token = "invalid"
|
||||||
task = api.get_task(uuid)
|
task = api.get_task(uuid)
|
||||||
self.assertRaises(NodeResponseError, task.download_assets, settings.MEDIA_TMP)
|
self.assertRaises(NodeResponseError, task.download_assets, settings.MEDIA_TMP)
|
||||||
|
|
||||||
api.token = "test_token"
|
api.token = "test_token"
|
||||||
asset_archive = task.download_zip(settings.MEDIA_TMP)
|
asset_archive = task.download_zip(settings.MEDIA_TMP)
|
||||||
self.assertTrue(os.path.exists(asset_archive))
|
self.assertTrue(os.path.exists(asset_archive))
|
||||||
os.unlink(asset_archive)
|
os.unlink(asset_archive)
|
||||||
|
|
||||||
# Cannot get task output without token
|
# Cannot get task output without token
|
||||||
api.token = "invalid"
|
api.token = "invalid"
|
||||||
self.assertRaises(NodeResponseError, task.output, 0)
|
self.assertRaises(NodeResponseError, task.output, 0)
|
||||||
|
|
||||||
api.token = "test_token"
|
api.token = "test_token"
|
||||||
res = task.output()
|
res = task.output()
|
||||||
self.assertTrue(isinstance(res, list))
|
self.assertTrue(isinstance(res, list))
|
||||||
|
|
||||||
# Cannot restart task without token
|
# Cannot restart task without token
|
||||||
online_node.token = "invalid"
|
online_node.token = "invalid"
|
||||||
self.assertRaises(NodeResponseError, online_node.restart_task, uuid)
|
self.assertRaises(NodeResponseError, online_node.restart_task, uuid)
|
||||||
|
|
||||||
online_node.token = "test_token"
|
online_node.token = "test_token"
|
||||||
self.assertTrue(online_node.restart_task(uuid))
|
self.assertTrue(online_node.restart_task(uuid))
|
||||||
|
|
||||||
# Cannot cancel task without token
|
# Cannot cancel task without token
|
||||||
online_node.token = "invalid"
|
online_node.token = "invalid"
|
||||||
self.assertRaises(NodeResponseError, online_node.cancel_task, uuid)
|
self.assertRaises(NodeResponseError, online_node.cancel_task, uuid)
|
||||||
online_node.token = "test_token"
|
online_node.token = "test_token"
|
||||||
self.assertTrue(online_node.cancel_task(uuid))
|
self.assertTrue(online_node.cancel_task(uuid))
|
||||||
|
|
||||||
# Wait for task to be canceled
|
# Wait for task to be canceled
|
||||||
wait_for_status(api, uuid, status_codes.CANCELED, 5, "Could not cancel task")
|
wait_for_status(api, uuid, status_codes.CANCELED, 5, "Could not cancel task")
|
||||||
|
|
||||||
# Cannot delete task without token
|
# Cannot delete task without token
|
||||||
online_node.token = "invalid"
|
online_node.token = "invalid"
|
||||||
self.assertRaises(NodeResponseError, online_node.remove_task, "invalid token")
|
self.assertRaises(NodeResponseError, online_node.remove_task, "invalid token")
|
||||||
online_node.token = "test_token"
|
online_node.token = "test_token"
|
||||||
self.assertTrue(online_node.remove_task(uuid))
|
self.assertTrue(online_node.remove_task(uuid))
|
||||||
|
|
||||||
node_odm.terminate()
|
|
||||||
|
|
Ładowanie…
Reference in New Issue