| 1 |
import uuid |
| 2 |
|
| 3 |
|
| 4 |
class test_Canvas: |
| 5 |
|
| 6 |
def test_freeze_reply_to(self): |
| 7 |
# Tests that Canvas.freeze() correctly |
| 8 |
# creates reply_to option |
| 9 |
|
| 10 |
@self.app.task |
| 11 |
def test_task(a, b): |
| 12 |
return |
| 13 |
|
| 14 |
s = test_task.s(2, 2) |
| 15 |
s.freeze() |
| 16 |
|
| 17 |
from concurrent.futures import ThreadPoolExecutor |
| 18 |
|
| 19 |
def foo(): |
| 20 |
s = test_task.s(2, 2) |
| 21 |
s.freeze() |
| 22 |
return self.app.thread_oid, s.options['reply_to'] |
| 23 |
with ThreadPoolExecutor(max_workers=1) as executor: |
| 24 |
future = executor.submit(foo) |
| 25 |
t_reply_to_app, t_reply_to_opt = future.result() |
| 26 |
|
| 27 |
assert uuid.UUID(s.options['reply_to']) |
| 28 |
assert uuid.UUID(t_reply_to_opt) |
| 29 |
# reply_to must be equal to thread_oid of Application |
| 30 |
assert self.app.thread_oid == s.options['reply_to'] |
| 31 |
assert t_reply_to_app == t_reply_to_opt |
| 32 |
# reply_to must be thread-relative. |
| 33 |
assert t_reply_to_opt != s.options['reply_to'] |