Closed gabroo closed 2 years ago
Hi Sajeev,
The changes in ff90fd2fb54c612fe6ab29708a2d5d984f60dea7 represent a structural change in how the gRPC code is generated, and there is no longer a LoggingServiceV2Servicer
. Some related code is now in google/cloud/logging_v2/_gapic.py, however you probably do not need to mock those classes. Instead, you might consider mocking the logging_api
member in the main Client
. Check out test_client.py for some examples of this.
If this doesn't meet your needs, please elaborate a little more on what you are trying to do with your tests.
Drew
Hi Drew,
Thanks for your response. I've been mocking the _LoggingAPI
class in client.py
as an interim solution, so that aligns with what you're saying. I'll let you know if some other issue comes up.
Hello,
I'm trying to write unit tests for some code that uses
logging.Client
. To do this, I'd like to create a mock gRPCLoggingServiceV2
server, but I cannot seem to find how to import theLoggingServiceV2Servicer
I need to extend in order to mock the service.Looking at the commit history of this repo, I noticed that version 2.0 introduced changes to the GAPIC layer described here.
It seems that the gRPC service definitions were moved from
google.cloud.logging_v2.proto
togoogle.cloud.logging_v2.services.logging_service_v2
. Although the client definition exists there, it appears the servicer definition was dropped.Is there a particular reason for this? If so, how can one import this class?
I've also tried using the
grpc-google-logging-v2
package but it doesn't seem to be compatible with this client library.