| 1 | from panoramisk import testing |
| 2 | import asyncio |
| 3 | import pytest |
| 4 | |
| 5 | |
| 6 | @pytest.fixture |
| 7 | def conn(request, event_loop): |
| 8 | |
| 9 | def callback(*args): |
| 10 | pass |
| 11 | |
| 12 | loop = asyncio.get_event_loop_policy().new_event_loop() |
| 13 | manager = testing.Manager(loop=loop) |
| 14 | manager.register_event('Peer*', callback) |
| 15 | return manager.protocol |
| 16 | |
| 17 | |
| 18 | def test_received(conn): |
| 19 | conn.data_received(b'Event: None\r\n\r\n') |
| 20 | conn.data_received(b'Event: PeerStatus\r\nPeer: gawel\r\n\r\n') |
| 21 | conn.data_received(b'Response: Follows\r\nPeer: gawel\r\n\r\n') |
| 22 | conn.data_received(b'Response: Success\r\nPing: Pong\r\n\r\n') |
| 23 | |
| 24 | |
| 25 | def test_send(conn): |
| 26 | assert isinstance(conn.send({}), asyncio.Future) |