python: remove grpc test cases

This commit is contained in:
なるみ 2022-04-13 23:27:44 +08:00
parent 20dfe4fbeb
commit 694b204238
2 changed files with 0 additions and 90 deletions

View File

@ -1,24 +0,0 @@
import bbgo_pb2
import bbgo_pb2_grpc
class TestTradingServicer(bbgo_pb2_grpc.TradingServiceServicer):
def SubmitOrder(self, request, context):
submit_order = request.submit_order
order = bbgo_pb2.Order(
exchange=submit_order.exchange,
symbol=submit_order.symbol,
side=submit_order.side,
quantity=submit_order.quantity,
price=submit_order.price,
stop_price=submit_order.stop_price,
order_type=submit_order.order_type,
client_order_id=submit_order.client_order_id,
group_id=submit_order.group_id,
)
error = bbgo_pb2.Error(error_code=0, error_message='')
return bbgo_pb2.SubmitOrderResponse(order=order, error=error)

View File

@ -1,66 +0,0 @@
from concurrent import futures
import bbgo_pb2
import bbgo_pb2_grpc
import grpc
import pytest
from bbgo import MarketService
from bbgo import TradingService
from tests.servicer import TestTradingServicer
@pytest.fixture
def address(host='[::]', port=50051):
return f'{host}:{port}'
@pytest.fixture
def channel(address):
return grpc.insecure_channel(address)
@pytest.fixture
def trading_service(channel):
trading_service_stub = bbgo_pb2_grpc.TradingServiceStub(channel)
return TradingService(trading_service_stub)
@pytest.fixture
def market_service(channel):
market_service_stub = bbgo_pb2_grpc.MarketDataServiceStub(channel)
return MarketService(market_service_stub)
@pytest.fixture
def test_trading_servicer(address, max_workers=1):
server = grpc.server(futures.ThreadPoolExecutor(max_workers))
servicer = TestTradingServicer()
bbgo_pb2_grpc.add_TradingServiceServicer_to_server(servicer, server)
server.add_insecure_port(address)
server.start()
yield server
server.stop(grace=None)
def test_submit_order(trading_service, test_trading_servicer):
exchange = 'max'
symbol = 'BTCUSDT'
side = bbgo_pb2.Side.BUY
quantity = 0.01
order_type = bbgo_pb2.OrderType.LIMIT
response = trading_service.submit_order(
exchange=exchange,
symbol=symbol,
side=side,
quantity=quantity,
order_type=order_type,
)
order = response.order
assert order.exchange == exchange
assert order.symbol == symbol
assert order.side == side
assert order.quantity == quantity