From d7ea902647bdeff691203773126d094ba27a9d1a Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 9 Sep 2020 16:24:59 +0100 Subject: [PATCH] Updated tests --- tests/test_default_views.py | 4 ++-- tests/test_tasks_thread.py | 32 ++++---------------------------- tests/test_views.py | 2 +- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/tests/test_default_views.py b/tests/test_default_views.py index 8616b2a7..3bd4071a 100644 --- a/tests/test_default_views.py +++ b/tests/test_default_views.py @@ -65,7 +65,7 @@ def task_func(): response = c.delete(f"/actions/{task_id}") assert response.status_code == 200 # Test task was stopped - assert task_obj._status == "stopped" + assert task_obj._status == "cancelled" def test_action_terminate(thing_client): @@ -85,7 +85,7 @@ def task_func(): response = c.delete(f"/actions/{task_id}", json={"timeout": "0"}) assert response.status_code == 200 # Test task was stopped - assert task_obj._status == "terminated" + assert task_obj._status == "cancelled" def test_action_kill_missing(thing_client): diff --git a/tests/test_tasks_thread.py b/tests/test_tasks_thread.py index 77be2ab0..f4375090 100644 --- a/tests/test_tasks_thread.py +++ b/tests/test_tasks_thread.py @@ -80,7 +80,7 @@ def task_func(): task_obj.start() task_obj.join() assert task_obj._return_value == "Return value" - assert task_obj._status == "success" + assert task_obj._status == "completed" def test_task_get(): @@ -140,7 +140,7 @@ def task_func(): assert task_obj._status == "running" task_obj.stop() task_obj.join() - assert task_obj._status == "stopped" + assert task_obj._status == "cancelled" assert task_obj._return_value is None @@ -155,7 +155,7 @@ def task_func(): assert task_obj._status == "running" task_obj.stop(timeout=0) task_obj.join() - assert task_obj._status == "terminated" + assert task_obj._status == "cancelled" assert task_obj._return_value is None @@ -170,7 +170,7 @@ def task_func(): assert task_obj._status == "running" task_obj.terminate() task_obj.join() - assert task_obj._status == "terminated" + assert task_obj._status == "cancelled" assert task_obj._return_value is None @@ -184,30 +184,6 @@ def task_func(): assert task_obj.terminate() is False -def test_task_log_list(): - import logging - import os - - logging.getLogger().setLevel("INFO") - - def task_func(): - logging.warning("Task warning") - for i in range(10): - logging.info(f"Counted to {i}") - - task_obj = thread.ActionThread(target=task_func) - task_obj.start() - task_obj.started.wait() - - task_obj.join() - assert task_obj.log[0]["message"] == "Task warning" - assert task_obj.log[0]["levelname"] == "WARNING" - assert task_obj.log[0]["filename"] == os.path.basename(__file__) - assert ( - len(task_obj.log) == 11 - ), "Didn't get the right number of log entries - are INFO entries being logged?" - - def test_task_log_without_thread(): task_log_handler = thread.ThreadLogHandler() diff --git a/tests/test_views.py b/tests/test_views.py index 9d985fe0..cf9ee21c 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -177,4 +177,4 @@ def post(self): action_thread = Index._deque[0] assert action_thread.default_stop_timeout == 0 action_thread.stop() - assert action_thread.status == "terminated" + assert action_thread.status == "cancelled"