示例#1
0
def test_AddMetadataBadEvent(events_server):
    _, _, status_code, _ = events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['AddMetadata'], {},
        events_pb2.AddMetadataRequest(event_id='1', key='foo',
                                      value='bar'), None).termination()
    assert status_code == grpc.StatusCode.NOT_FOUND
示例#2
0
def test_AddMetadata_NoneKey(events_server):
    events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['OpenEvent'], {},
        events_pb2.OpenEventRequest(event_id='1'), None)
    _, _, status_code, _ = events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['AddMetadata'], {},
        events_pb2.AddMetadataRequest(event_id='1', key=None,
                                      value='bar'), None).termination()
    assert status_code == grpc.StatusCode.INVALID_ARGUMENT
示例#3
0
def test_GetAllMetadata(events_server):
    events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['OpenEvent'], {},
        events_pb2.OpenEventRequest(event_id='1'), None)
    events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['AddMetadata'], {},
        events_pb2.AddMetadataRequest(event_id='1', key='foo',
                                      value='bar'), None)
    events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['AddMetadata'], {},
        events_pb2.AddMetadataRequest(event_id='1', key='baz',
                                      value='buh'), None)
    response, _, _, _ = events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['GetAllMetadata'], {},
        events_pb2.GetAllMetadataRequest(event_id='1'), None).termination()
    d = dict(response.metadata)
    assert d == {'foo': 'bar', 'baz': 'buh'}
示例#4
0
 def add_metadata(self, event_id, key, value):
     request = events_pb2.AddMetadataRequest(event_id=event_id,
                                             key=key,
                                             value=value)
     response = self.stub.AddMetadata(request)
     return response is not None