diff options
| author | bozo.kopic <bozo@kopic.xyz> | 2021-07-28 01:43:55 +0200 |
|---|---|---|
| committer | bozo.kopic <bozo@kopic.xyz> | 2021-07-29 00:01:57 +0200 |
| commit | 1e874e790c12839695761a654b44fb427149a353 (patch) | |
| tree | 6942441ac511ec1417b2434b111101fa8d7f7e68 /test_pytest/test_server.py | |
init
Diffstat (limited to 'test_pytest/test_server.py')
| -rw-r--r-- | test_pytest/test_server.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test_pytest/test_server.py b/test_pytest/test_server.py new file mode 100644 index 0000000..2287f57 --- /dev/null +++ b/test_pytest/test_server.py @@ -0,0 +1,50 @@ +import itertools + +import pytest + +from hat import aio +from hat import util + +import restlog.server + + +pytestmark = pytest.mark.asyncio + + +@pytest.fixture +def port(): + return util.get_unused_tcp_port() + + +class Backend(aio.Resource): + + def __init__(self): + self._async_group = aio.Group() + self._next_entry_ids = itertools.count(1) + + @property + def async_group(self): + return self._async_group + + async def register(self, timestamp, address, source, type, data): + return {'entry_id': next(self._next_entry_ids), + 'timestamp': timestamp, + 'address': address, + 'source': source, + 'type': type, + 'data': data} + + async def get_entries(self, source=None, type=None, last_entry_id=None, + max_results=None): + return {'entries': [], + 'more': False} + + async def get_entry(self, entry_id): + return + + +async def test_create(port): + backend = Backend() + server = await restlog.server.create('127.0.0.1', port, backend) + assert server.is_open + await server.async_close() |
