コード例 #1
0
ファイル: test_lease.py プロジェクト: zhangzifa/spot-sdk
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
ファイル: test_lease.py プロジェクト: zhangzifa/spot-sdk
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
ファイル: helpers.py プロジェクト: greck2908/spot-sdk
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
ファイル: test_lease.py プロジェクト: greck2908/spot-sdk
def body_lease_proto():
    proto = LeaseProto.Lease()
    proto.resource = 'body'
    proto.sequence[:] = [1]
    proto.epoch = 'epoch'
    return proto