Ejemplo n.º 1
0
def test_GetAllBinaryDataNames(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['AddBinaryData'], {},
        events_pb2.AddBinaryDataRequest(event_id='1',
                                        binary_data_name='a',
                                        binary_data=b'\xBF\xAF'), None)
    events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['AddBinaryData'], {},
        events_pb2.AddBinaryDataRequest(event_id='1',
                                        binary_data_name='b',
                                        binary_data=b'\xAF\xBF'), None)
    response, _, _, _ = events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['GetAllBinaryDataNames'], {},
        events_pb2.GetAllBinaryDataNamesRequest(event_id='1'),
        None).termination()
    assert 'a' in response.binary_data_names
    assert 'b' in response.binary_data_names
    assert len(response.binary_data_names) == 2
Ejemplo n.º 2
0
 def add_binary_data(self, event_id: str, binary_data_name: str,
                     binary_data: bytes):
     request = events_pb2.AddBinaryDataRequest(
         event_id=event_id,
         binary_data_name=binary_data_name,
         binary_data=binary_data)
     response = self.stub.AddBinaryData(request)
     return response is not None
Ejemplo n.º 3
0
def test_AddGetBinaryData(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['AddBinaryData'], {},
        events_pb2.AddBinaryDataRequest(event_id='1',
                                        binary_data_name='a',
                                        binary_data=b'\xBF\xAF'), None)
    response, _, _, _ = events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['GetBinaryData'], {},
        events_pb2.GetBinaryDataRequest(event_id='1', binary_data_name='a'),
        None).termination()
    assert response.binary_data == b'\xBF\xAF'