1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/tests/test_network.py

24 lines
754 B
Python
Raw Permalink Normal View History

2019-10-15 09:07:04 +00:00
import pytest
import uuid
import royalherald as h
async def echo_request_handler(message):
return message
def test_package_serialization():
pkg = h.Package({"ciao": "ciao"},
source=str(uuid.uuid4()),
destination=str(uuid.uuid4()),
source_conv_id=str(uuid.uuid4()),
destination_conv_id=str(uuid.uuid4()))
assert pkg == h.Package.from_dict(pkg.to_dict())
assert pkg == h.Package.from_json_string(pkg.to_json_string())
assert pkg == h.Package.from_json_bytes(pkg.to_json_bytes())
def test_request_creation():
request = h.Request("pytest", {"testing": "is fun", "bugs": "are less fun"})
assert request == h.Request.from_dict(request.to_dict())