Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from yfrake import client |
||
2 | from concurrent import futures |
||
3 | import threading |
||
4 | import asyncio |
||
5 | import pytest |
||
6 | import sys |
||
7 | |||
8 | |||
9 | if sys.platform == 'win32': |
||
10 | asyncio.set_event_loop_policy( |
||
11 | asyncio.WindowsSelectorEventLoopPolicy() |
||
12 | ) |
||
13 | |||
14 | |||
15 | def test_client_response_1(): |
||
16 | @client.session |
||
17 | def inner(): |
||
18 | resp = client.get(endpoint='quote_type', symbol='msft') |
||
19 | resp.wait() |
||
20 | assert isinstance(resp.event, threading.Event) |
||
21 | assert isinstance(resp.future, futures.Future) |
||
22 | inner() |
||
23 | |||
24 | |||
25 | async def test_client_response_2(): |
||
26 | @client.session |
||
27 | async def inner(): |
||
28 | resp = client.get(endpoint='quote_type', symbol='msft') |
||
29 | await resp.wait() |
||
30 | assert isinstance(resp.event, asyncio.Event) |
||
31 | assert isinstance(resp.future, asyncio.Task) |
||
32 | await inner() |
||
33 | |||
34 | |||
35 | def test_client_response_3(): |
||
36 | @client.session |
||
37 | def inner(): |
||
38 | resp = client.get(endpoint='quote_type', symbol='msft') |
||
39 | resp.wait() |
||
40 | for attr in ['event', 'future']: |
||
41 | with pytest.raises(TypeError): |
||
42 | setattr(resp, attr, str()) |
||
43 | with pytest.raises(TypeError): |
||
44 | delattr(resp, attr) |
||
45 | inner() |
||
46 |