grpc: removed set session location, achieved with start session

This commit is contained in:
Blake Harnden 2021-04-27 10:59:10 -07:00
parent e0fe86bcb2
commit a217c2445c
6 changed files with 0 additions and 130 deletions

View file

@ -314,39 +314,6 @@ class CoreGrpcClient:
)
return self.stub.SetSessionMetadata(request)
def set_session_location(
self,
session_id: int,
x: float = None,
y: float = None,
z: float = None,
lat: float = None,
lon: float = None,
alt: float = None,
scale: float = None,
) -> core_pb2.SetSessionLocationResponse:
"""
Set session location.
:param session_id: id of session
:param x: x position
:param y: y position
:param z: z position
:param lat: latitude position
:param lon: longitude position
:param alt: altitude position
:param scale: geo scale
:return: response with result of success or failure
:raises grpc.RpcError: when session doesn't exist
"""
location = core_pb2.SessionLocation(
x=x, y=y, z=z, lat=lat, lon=lon, alt=alt, scale=scale
)
request = core_pb2.SetSessionLocationRequest(
session_id=session_id, location=location
)
return self.stub.SetSessionLocation(request)
def set_session_state(
self, session_id: int, state: core_pb2.SessionState
) -> core_pb2.SetSessionStateResponse:

View file

@ -427,23 +427,6 @@ class CoreGrpcClient:
response = self.stub.SetSessionMetadata(request)
return response.result
def set_session_location(
self, session_id: int, location: wrappers.SessionLocation
) -> bool:
"""
Set session location.
:param session_id: id of session
:param location: session location
:return: True for success, False otherwise
:raises grpc.RpcError: when session doesn't exist
"""
request = core_pb2.SetSessionLocationRequest(
session_id=session_id, location=location.to_proto()
)
response = self.stub.SetSessionLocation(request)
return response.result
def set_session_state(self, session_id: int, state: wrappers.SessionState) -> bool:
"""
Set session state.

View file

@ -390,21 +390,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
sessions.append(session_summary)
return core_pb2.GetSessionsResponse(sessions=sessions)
def SetSessionLocation(
self, request: core_pb2.SetSessionLocationRequest, context: ServicerContext
) -> core_pb2.SetSessionLocationResponse:
"""
Set session location
:param request: set-session-location request
:param context: context object
:return: a set-session-location-response
"""
logger.debug("set session location: %s", request)
session = self.get_session(request.session_id, context)
grpcutils.session_location(session, request.location)
return core_pb2.SetSessionLocationResponse(result=True)
def SetSessionState(
self, request: core_pb2.SetSessionStateRequest, context: ServicerContext
) -> core_pb2.SetSessionStateResponse:

View file

@ -27,8 +27,6 @@ service CoreApi {
}
rpc SetSessionMetadata (SetSessionMetadataRequest) returns (SetSessionMetadataResponse) {
}
rpc SetSessionLocation (SetSessionLocationRequest) returns (SetSessionLocationResponse) {
}
rpc SetSessionState (SetSessionStateRequest) returns (SetSessionStateResponse) {
}
rpc AddSessionServer (AddSessionServerRequest) returns (AddSessionServerResponse) {
@ -245,15 +243,6 @@ message SetSessionMetadataResponse {
bool result = 1;
}
message SetSessionLocationRequest {
int32 session_id = 1;
SessionLocation location = 2;
}
message SetSessionLocationResponse {
bool result = 1;
}
message SetSessionStateRequest {
int32 session_id = 1;
SessionState.Enum state = 2;

View file

@ -236,33 +236,6 @@ class TestGrpc:
assert len(response.sessions) == 1
assert found_session is not None
def test_set_session_location(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
# then
scale = 2
xyz = (1, 1, 1)
lat_lon_alt = (1, 1, 1)
with client.context_connect():
response = client.set_session_location(
session.id,
x=xyz[0],
y=xyz[1],
z=xyz[2],
lat=lat_lon_alt[0],
lon=lat_lon_alt[1],
alt=lat_lon_alt[2],
scale=scale,
)
# then
assert response.result is True
assert session.location.refxyz == xyz
assert session.location.refscale == scale
assert session.location.refgeo == lat_lon_alt
def test_set_session_metadata(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()

View file

@ -280,33 +280,6 @@ class TestGrpcw:
assert len(sessions) == 1
assert found_session is not None
def test_set_session_location(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
scale = 2
xyz = (1, 1, 1)
lat_lon_alt = (1, 1, 1)
location = SessionLocation(
xyz[0],
xyz[1],
xyz[2],
lat_lon_alt[0],
lat_lon_alt[1],
lat_lon_alt[2],
scale,
)
# then
with client.context_connect():
result = client.set_session_location(session.id, location)
# then
assert result is True
assert session.location.refxyz == xyz
assert session.location.refscale == scale
assert session.location.refgeo == lat_lon_alt
def test_set_session_metadata(self, grpc_server: CoreGrpcServer):
# given
client = CoreGrpcClient()