コード例 #1
0
def test_set_localization_exceptions(client, service, server):
    make_call = lambda: client.set_localization(nav_pb2.Localization())
    make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OLDER)
    with pytest.raises(bosdyn.client.LeaseUseError):
        make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OK)
    make_call()

    service.set_loc_resp.status = service.set_loc_resp.STATUS_ROBOT_IMPAIRED
    with pytest.raises(bosdyn.client.graph_nav.RobotFaultedError):
        make_call()

    service.set_loc_resp.status = service.set_loc_resp.STATUS_UNKNOWN_WAYPOINT
    with pytest.raises(bosdyn.client.graph_nav.UnknownMapInformationError):
        make_call()

    service.set_loc_resp.status = service.set_loc_resp.STATUS_ABORTED
    with pytest.raises(bosdyn.client.graph_nav.RequestAbortedError):
        make_call()

    service.set_loc_resp.status = service.set_loc_resp.STATUS_FAILED
    with pytest.raises(bosdyn.client.graph_nav.RequestFailedError):
        make_call()
コード例 #2
0
def test_navigate_to_exceptions(client, service, server):
    make_call = lambda: client.navigate_to('somewhere-id', 2.0)
    cmd_id = make_call()
    assert type(cmd_id) is int

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OLDER)
    with pytest.raises(bosdyn.client.LeaseUseError):
        make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OK)
    cmd_id = make_call()
    assert type(cmd_id) is int

    service.nav_to_resp.status = service.nav_to_resp.STATUS_NO_TIMESYNC
    with pytest.raises(bosdyn.client.graph_nav.NoTimeSyncError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_EXPIRED
    with pytest.raises(bosdyn.client.graph_nav.CommandExpiredError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_TOO_DISTANT
    with pytest.raises(bosdyn.client.graph_nav.TooDistantError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_ROBOT_IMPAIRED
    with pytest.raises(bosdyn.client.graph_nav.RobotImpairedError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_RECORDING
    with pytest.raises(bosdyn.client.graph_nav.IsRecordingError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_UNKNOWN_WAYPOINT
    with pytest.raises(bosdyn.client.graph_nav.UnknownWaypointError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_NO_PATH
    with pytest.raises(bosdyn.client.graph_nav.NoPathError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_FEATURE_DESERT
    with pytest.raises(bosdyn.client.graph_nav.FeatureDesertError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_LOST
    with pytest.raises(bosdyn.client.graph_nav.RobotLostError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_NOT_LOCALIZED_TO_MAP
    with pytest.raises(bosdyn.client.graph_nav.RobotNotLocalizedToRouteError):
        make_call()

    service.nav_to_resp.status = service.nav_to_resp.STATUS_COULD_NOT_UPDATE_ROUTE
    with pytest.raises(bosdyn.client.graph_nav.RouteNotUpdatingError):
        make_call()
コード例 #3
0
def test_upload_edge_exceptions(client, service, server):
    make_call = lambda: client.upload_edge_snapshot(map_pb2.EdgeSnapshot())
    make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OLDER)
    with pytest.raises(bosdyn.client.LeaseUseError):
        make_call()
コード例 #4
0
def test_upload_graph_exceptions(client, service, server):
    make_call = lambda: client.upload_graph(graph=map_pb2.Graph())
    make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OLDER)
    with pytest.raises(bosdyn.client.LeaseUseError):
        make_call()
コード例 #5
0
ファイル: test_lease.py プロジェクト: zhangzifa/spot-sdk
def _create_lease_use_result(status, attempted_lease, previous_lease=None):
    lease_use_result = LeaseProto.LeaseUseResult()
    lease_use_result.status = status
    lease_use_result.owner.client_name = 'foobar'
    lease_use_result.owner.user_name = 'garbanzo'
    lease_use_result.attempted_lease.CopyFrom(attempted_lease.lease_proto)
    if previous_lease:
        lease_use_result.previous_lease.CopyFrom(previous_lease.lease_proto)
    return lease_use_result
コード例 #6
0
def test_clear_graph(client, service, server):
    make_call = lambda: client.clear_graph()

    make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OLDER)
    with pytest.raises(bosdyn.client.LeaseUseError):
        make_call()
コード例 #7
0
def test_upload_graph_exceptions(client, service, server):
    make_call = lambda: client.upload_graph(graph=map_pb2.Graph())
    make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OLDER)
    with pytest.raises(bosdyn.client.LeaseUseError):
        make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OK)
    make_call()

    service.upload_graph_resp.status = service.upload_graph_resp.STATUS_MAP_TOO_LARGE_LICENSE
    with pytest.raises(bosdyn.client.graph_nav.MapTooLargeLicenseError):
        make_call()

    service.upload_graph_resp.status = service.upload_graph_resp.STATUS_INVALID_GRAPH
    with pytest.raises(bosdyn.client.graph_nav.InvalidGraphError):
        make_call()
コード例 #8
0
def test_navigate_route_exceptions(client, service, server):
    make_call = lambda: client.navigate_route(nav_pb2.Route(), 2.0)
    cmd_id = make_call()
    assert cmd_id == 0
    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OLDER)
    with pytest.raises(bosdyn.client.LeaseUseError):
        make_call()

    service.lease_use_result = lease_pb2.LeaseUseResult(
        status=lease_pb2.LeaseUseResult.STATUS_OK)
    cmd_id = make_call()
    assert type(cmd_id) is int

    service.nav_route_resp.status = service.nav_route_resp.STATUS_NO_TIMESYNC
    with pytest.raises(bosdyn.client.graph_nav.NoTimeSyncError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_EXPIRED
    with pytest.raises(bosdyn.client.graph_nav.CommandExpiredError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_TOO_DISTANT
    with pytest.raises(bosdyn.client.graph_nav.TooDistantError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_ROBOT_IMPAIRED
    with pytest.raises(bosdyn.client.graph_nav.RobotImpairedError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_RECORDING
    with pytest.raises(bosdyn.client.graph_nav.IsRecordingError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_UNKNOWN_ROUTE_ELEMENTS
    with pytest.raises(bosdyn.client.graph_nav.UnknownRouteElementsError):
        make_call()
    #make sure the misspelled error works for backwards compatibility.
    with pytest.raises(bosdyn.client.graph_nav.UnkownRouteElementsError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_INVALID_EDGE
    with pytest.raises(bosdyn.client.graph_nav.InvalidEdgeError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_CONSTRAINT_FAULT
    with pytest.raises(bosdyn.client.graph_nav.ConstraintFaultError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_FEATURE_DESERT
    with pytest.raises(bosdyn.client.graph_nav.FeatureDesertError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_LOST
    with pytest.raises(bosdyn.client.graph_nav.RobotLostError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_NOT_LOCALIZED_TO_ROUTE
    with pytest.raises(bosdyn.client.graph_nav.RobotNotLocalizedToRouteError):
        make_call()

    service.nav_route_resp.status = service.nav_route_resp.STATUS_COULD_NOT_UPDATE_ROUTE
    with pytest.raises(bosdyn.client.graph_nav.RouteNotUpdatingError):
        make_call()