tests(server): test storing (#64)

This commit is contained in:
joriscarrier 2019-01-15 22:57:45 +01:00 committed by Brian Muller
parent 483ff455e7
commit 4cd8488ed7
3 changed files with 30 additions and 0 deletions

View File

@ -4,3 +4,4 @@ sphinx>=1.6.5
sphinxcontrib-napoleon>=0.6.1
sphinxcontrib-zopeext>=0.2.1
pytest>=4.1.0
pytest-asyncio>=0.10.0

View File

@ -0,0 +1,14 @@
import pytest
from kademlia.network import Server
@pytest.yield_fixture
def bootstrap_node(event_loop):
server = Server()
event_loop.run_until_complete(server.listen(8468))
try:
yield ('127.0.0.1', 8468)
finally:
server.stop()

View File

@ -1,10 +1,25 @@
import unittest
import asyncio
import pytest
from kademlia.network import Server
from kademlia.protocol import KademliaProtocol
@pytest.mark.asyncio
async def test_storing(bootstrap_node):
server = Server()
await server.listen(bootstrap_node[1] + 1)
await server.bootstrap([bootstrap_node])
await server.set('key', 'value')
result = await server.get('key')
assert result == 'value'
server.stop()
class SwappableProtocolTests(unittest.TestCase):
def test_default_protocol(self):