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 -----
- Register service 1 with grpc_testing.server_from_dictionary
- Create a mock for service 2
----- When testing the method calling service 2 ----
- Register service 2 mock to intercept requests
- Invoke_unary_unay
- Service 2 return the mock value
- Collect result of method in service 1
Points 1 and 3 from part 2 are what I am struggling with.
I nonetheless would like to know if any of you have any tip on this please ?
Thank you in advance !
Sincerly,