def test_bad_lease_constructors(): with pytest.raises(ValueError) as e_info: Lease(None) with pytest.raises(ValueError) as e_info: lease_proto = LeaseProto.Lease() Lease(lease_proto) with pytest.raises(ValueError) as e_info: lease_proto = LeaseProto.Lease() lease_proto.resource = LLAMA Lease(lease_proto) with pytest.raises(ValueError) as e_info: lease_proto = LeaseProto.Lease() lease_proto.sequence[:] = SEQ Lease(lease_proto)
def test_get_lease_state(): """Check the LeaseWalletRequestProcessor.get_lease_state() method""" proc = LeaseWalletRequestProcessor single_lease_unset_request = robot_command_pb2.RobotCommandRequest() single_lease_set_request = robot_command_pb2.RobotCommandRequest(lease=lease_pb2.Lease()) no_lease_request = robot_command_pb2.RobotCommandFeedbackRequest() multi_lease, skip_mut = LeaseWalletRequestProcessor.get_lease_state(single_lease_unset_request) assert not multi_lease assert not skip_mut multi_lease, skip_mut = LeaseWalletRequestProcessor.get_lease_state(single_lease_set_request) assert not multi_lease assert skip_mut multi_lease, skip_mut = LeaseWalletRequestProcessor.get_lease_state(no_lease_request) assert multi_lease is None assert skip_mut
def _create_lease(resource, epoch, sequence): lease_proto = LeaseProto.Lease() lease_proto.resource = resource lease_proto.epoch = epoch lease_proto.sequence[:] = sequence return Lease(lease_proto)
def build_lease(sequence, epoch='foo', resource='bar'): lease = lease_pb2.Lease(resource=resource, epoch=epoch) lease.sequence.extend(sequence) return lease
def __init__(self): self.lease_proto = lease_pb2.Lease()
def body_lease_proto(): proto = LeaseProto.Lease() proto.resource = 'body' proto.sequence[:] = [1] proto.epoch = 'epoch' return proto