Thank you for your reply ! Fake server is indeed the solution i used until now. Thanks for the example, it somehow corresponds to what i was looking for.
Have a nice day. Le mercredi 8 juin 2022 à 20:42:28 UTC+2, Lidi Zheng a écrit : > For implementing the testing interceptor, you might find this example > useful: > https://github.com/grpc/grpc/tree/master/examples/python/interceptors/default_value, > > which injects default response value. > > Alternatively, you could create a fake server instead. This will ensure > you are only testing the intended parts of your service. > > On Friday, June 3, 2022 at 5:47:26 AM UTC-7 Fabien wrote: > >> Hi all, >> >> I am currently working on writing tests to my service implemented with >> grpc python - using grpc_testing package. >> >> Everything has been quite smooth until now, using the inovke methods and >> so on which works very well. >> >> However i'm now having a hard time : one of my service - let's call it >> service 1 - has a method which call another service - service 2 -, the >> current implementation create the stub channel directly in the method from >> service 1 with a given ip and port. >> As such, I would like in my tests for this method (in service 1) to >> intercept every request adressed to service 2 (could it be done >> independently of any ip / port given in the real implementation ?) and >> return a mock value when necessary. >> >> So far here is how i see things : >> >> ----- Set up step ----- >> >> 1. Register service 1 with grpc_testing.server_from_dictionary >> 2. Create a mock for service 2 >> >> ----- When testing the method calling service 2 ---- >> >> 1. Register service 2 mock to intercept requests >> 2. Invoke_unary_unay >> 3. Service 2 return the mock value >> 4. Collect result of method in service 1 >> >> Points 1 and 3 from part 2 are what I am struggling with. >> >> I have seen the examples in >> https://github.com/grpc/grpc/tree/master/src/python/grpcio_tests/tests/testing >> >> and the client test is what I found to be the more interesting for the >> given points, but is not consistent with my current implementation. >> I nonetheless would like to know if any of you have any tip on this >> please ? >> >> Thank you in advance ! >> >> Sincerly, >> > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/8e1d093c-6f5c-4fec-b68e-5fee4dabfb03n%40googlegroups.com.
