Пример #1
0
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)
Пример #2
0
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
Пример #3
0
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)
Пример #4
0
def build_lease(sequence, epoch='foo', resource='bar'):
    lease = lease_pb2.Lease(resource=resource, epoch=epoch)
    lease.sequence.extend(sequence)
    return lease
Пример #5
0
 def __init__(self):
     self.lease_proto = lease_pb2.Lease()
Пример #6
0
def body_lease_proto():
    proto = LeaseProto.Lease()
    proto.resource = 'body'
    proto.sequence[:] = [1]
    proto.epoch = 'epoch'
    return proto