Issue #45: scaffold Python package
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""Tests for the Python CLI scaffold."""
|
||||
|
||||
import json
|
||||
|
||||
from click.testing import CliRunner
|
||||
|
||||
from mxgateway import __version__
|
||||
from mxgateway_cli.commands import main
|
||||
|
||||
|
||||
def test_version_json_is_deterministic() -> None:
|
||||
runner = CliRunner()
|
||||
|
||||
result = runner.invoke(main, ["version", "--json"])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert json.loads(result.output) == {
|
||||
"client": "mxgw-py",
|
||||
"package": "mxaccess-gateway-client",
|
||||
"version": __version__,
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Tests for generated protobuf and gRPC module importability."""
|
||||
|
||||
from mxgateway.generated import mxaccess_gateway_pb2
|
||||
from mxgateway.generated import mxaccess_gateway_pb2_grpc
|
||||
from mxgateway.generated import mxaccess_worker_pb2
|
||||
|
||||
|
||||
def test_gateway_messages_import() -> None:
|
||||
request = mxaccess_gateway_pb2.OpenSessionRequest(
|
||||
client_session_name="pytest",
|
||||
client_correlation_id="test-correlation",
|
||||
)
|
||||
|
||||
assert request.client_session_name == "pytest"
|
||||
assert hasattr(mxaccess_gateway_pb2_grpc, "MxAccessGatewayStub")
|
||||
|
||||
|
||||
def test_worker_messages_import_gateway_types() -> None:
|
||||
envelope = mxaccess_worker_pb2.WorkerEnvelope(
|
||||
protocol_version=1,
|
||||
session_id="test-session",
|
||||
worker_command=mxaccess_worker_pb2.WorkerCommand(
|
||||
command=mxaccess_gateway_pb2.MxCommand(
|
||||
kind=mxaccess_gateway_pb2.MX_COMMAND_KIND_PING,
|
||||
ping=mxaccess_gateway_pb2.PingCommand(message="hello"),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
assert envelope.worker_command.command.ping.message == "hello"
|
||||
Reference in New Issue
Block a user