Fix interop pubsub tests and PR feedback

- Use `from_id`, the changed field name in `PSMessage`.
- PR feedbacks
        - Add label `test` in `testenv` in tox.ini, to avoid wrong
dispatching an environment's command in the future.
        - Use `pytest` over `py.test`.
This commit is contained in:
mhchia 2019-09-24 11:30:52 +08:00
parent 19c17dd512
commit d1c25b8b1e
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A
4 changed files with 11 additions and 6 deletions

View File

@ -195,7 +195,11 @@ class Pubsub:
# Ref: https://developers.google.com/protocol-buffers/docs/reference/python-generated#singular-fields-proto2 # noqa: E501 # Ref: https://developers.google.com/protocol-buffers/docs/reference/python-generated#singular-fields-proto2 # noqa: E501
if rpc_incoming.HasField("control"): if rpc_incoming.HasField("control"):
# Pass rpc to router so router could perform custom logic # Pass rpc to router so router could perform custom logic
logger.debug("received `control` message %s from peer %s", peer_id) logger.debug(
"received `control` message %s from peer %s",
rpc_incoming.control,
peer_id,
)
await self.router.handle_rpc(rpc_incoming, peer_id) await self.router.handle_rpc(rpc_incoming, peer_id)
# Force context switch # Force context switch

View File

@ -8,7 +8,6 @@ extras_require = {
"factory-boy>=2.12.0,<3.0.0", "factory-boy>=2.12.0,<3.0.0",
"pytest>=4.6.3,<5.0.0", "pytest>=4.6.3,<5.0.0",
"pytest-asyncio>=0.10.0,<1.0.0", "pytest-asyncio>=0.10.0,<1.0.0",
"pexpect>=4.6,<5",
], ],
"lint": [ "lint": [
"mypy>=0.701,<1.0", "mypy>=0.701,<1.0",

View File

@ -38,7 +38,7 @@ async def p2pd_subscribe(p2pd, topic) -> "asyncio.Queue[rpc_pb2.Message]":
ps_msg.ParseFromString(msg_bytes) ps_msg.ParseFromString(msg_bytes)
# Fill in the message used in py-libp2p # Fill in the message used in py-libp2p
msg = rpc_pb2.Message( msg = rpc_pb2.Message(
from_id=ps_msg.from_field, from_id=ps_msg.from_id,
data=ps_msg.data, data=ps_msg.data,
seqno=ps_msg.seqno, seqno=ps_msg.seqno,
topicIDs=ps_msg.topicIDs, topicIDs=ps_msg.topicIDs,

View File

@ -30,7 +30,7 @@ deps =
passenv = CI TRAVIS TRAVIS_* passenv = CI TRAVIS TRAVIS_*
extras = test extras = test
commands = commands =
py.test tests/ test: pytest tests/
basepython = basepython =
py37: python3.7 py37: python3.7
@ -44,10 +44,12 @@ commands =
flake8 libp2p tests tests_interop examples setup.py flake8 libp2p tests tests_interop examples setup.py
[testenv:py37-interop] [testenv:py37-interop]
deps = p2pclient deps =
p2pclient
pexpect
passenv = CI TRAVIS TRAVIS_* GOPATH passenv = CI TRAVIS TRAVIS_* GOPATH
extras = test extras = test
commands = commands =
py.test tests_interop/ pytest tests_interop/
basepython = basepython =
py37: python3.7 py37: python3.7