Skip to content

Commit d7ea902

Browse files
author
Joel Collins
committed
Updated tests
1 parent ccc07ab commit d7ea902

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

tests/test_default_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def task_func():
6565
response = c.delete(f"/actions/{task_id}")
6666
assert response.status_code == 200
6767
# Test task was stopped
68-
assert task_obj._status == "stopped"
68+
assert task_obj._status == "cancelled"
6969

7070

7171
def test_action_terminate(thing_client):
@@ -85,7 +85,7 @@ def task_func():
8585
response = c.delete(f"/actions/{task_id}", json={"timeout": "0"})
8686
assert response.status_code == 200
8787
# Test task was stopped
88-
assert task_obj._status == "terminated"
88+
assert task_obj._status == "cancelled"
8989

9090

9191
def test_action_kill_missing(thing_client):

tests/test_tasks_thread.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def task_func():
8080
task_obj.start()
8181
task_obj.join()
8282
assert task_obj._return_value == "Return value"
83-
assert task_obj._status == "success"
83+
assert task_obj._status == "completed"
8484

8585

8686
def test_task_get():
@@ -140,7 +140,7 @@ def task_func():
140140
assert task_obj._status == "running"
141141
task_obj.stop()
142142
task_obj.join()
143-
assert task_obj._status == "stopped"
143+
assert task_obj._status == "cancelled"
144144
assert task_obj._return_value is None
145145

146146

@@ -155,7 +155,7 @@ def task_func():
155155
assert task_obj._status == "running"
156156
task_obj.stop(timeout=0)
157157
task_obj.join()
158-
assert task_obj._status == "terminated"
158+
assert task_obj._status == "cancelled"
159159
assert task_obj._return_value is None
160160

161161

@@ -170,7 +170,7 @@ def task_func():
170170
assert task_obj._status == "running"
171171
task_obj.terminate()
172172
task_obj.join()
173-
assert task_obj._status == "terminated"
173+
assert task_obj._status == "cancelled"
174174
assert task_obj._return_value is None
175175

176176

@@ -184,30 +184,6 @@ def task_func():
184184
assert task_obj.terminate() is False
185185

186186

187-
def test_task_log_list():
188-
import logging
189-
import os
190-
191-
logging.getLogger().setLevel("INFO")
192-
193-
def task_func():
194-
logging.warning("Task warning")
195-
for i in range(10):
196-
logging.info(f"Counted to {i}")
197-
198-
task_obj = thread.ActionThread(target=task_func)
199-
task_obj.start()
200-
task_obj.started.wait()
201-
202-
task_obj.join()
203-
assert task_obj.log[0]["message"] == "Task warning"
204-
assert task_obj.log[0]["levelname"] == "WARNING"
205-
assert task_obj.log[0]["filename"] == os.path.basename(__file__)
206-
assert (
207-
len(task_obj.log) == 11
208-
), "Didn't get the right number of log entries - are INFO entries being logged?"
209-
210-
211187
def test_task_log_without_thread():
212188

213189
task_log_handler = thread.ThreadLogHandler()

tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,4 @@ def post(self):
177177
action_thread = Index._deque[0]
178178
assert action_thread.default_stop_timeout == 0
179179
action_thread.stop()
180-
assert action_thread.status == "terminated"
180+
assert action_thread.status == "cancelled"

0 commit comments

Comments
 (0)