Beispiel #1
0
def test_GetDocumentText_bad_event(events_server):
    _, _, status_code, _ = events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['GetDocumentText'], {},
        events_pb2.GetDocumentTextRequest(event_id='1',
                                          document_name='plaintext'),
        None).termination()
    assert status_code == grpc.StatusCode.NOT_FOUND
Beispiel #2
0
def test_GetDocumentText(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['AddDocument'], {},
        events_pb2.AddDocumentRequest(event_id='1',
                                      document_name='plaintext',
                                      text=PHASERS), None)
    response, _, _, _ = events_server.invoke_unary_unary(
        events_pb2.DESCRIPTOR.services_by_name['Events'].
        methods_by_name['GetDocumentText'], {},
        events_pb2.GetDocumentTextRequest(event_id='1',
                                          document_name='plaintext'),
        None).termination()
    assert response.text == PHASERS
Beispiel #3
0
 def get_document_text(self, event_id, document_name):
     request = events_pb2.GetDocumentTextRequest(
         event_id=event_id, document_name=document_name)
     response = self.stub.GetDocumentText(request)
     return response.text