taverntesting / tavern

A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax
https://taverntesting.github.io/
MIT License
1.02k stars 192 forks source link

gRPC multi stage test #915

Closed AmaniKhalifa closed 6 months ago

AmaniKhalifa commented 6 months ago

Is there a current support for saving a variable from the response of one stage to be used in a next stage for grpc_response.

I see there's a support for http requests using the "save" key.

https://tavern.readthedocs.io/en/latest/examples.html#multi-stage-tests

I think "save" is not expected in the grpc_response keys as I see from here: https://github.com/taverntesting/tavern/blob/da51cd46aa14d6ef76bf5cbf4aba8c946344d783/tavern/_plugins/grpc/response.py#L49C40-L49C47

Is there any other way to do so?

michaelboulton commented 6 months ago

There was something missing causing this to fail, I've rectified it in version 2.9.2. This was just beacuse of some old key checking code which needed fixing anyway

AmaniKhalifa commented 6 months ago

Thanks @michaelboulton seems it's only saved if we verify the same variable we want to save in the body. While this will work because of checking the body.message:

   grpc_response:
      status: "OK"
      body:
        message: "Hello, John!"
      save:
        body:
          received_message: message

so this will fail:

    grpc_response:
      status: "OK"
      save:
        body:
          received_message: message

For grpc_response, I cannot see any support for arbitrary specific types like anyint, anystr ... etc so does this mean that I need to know the value of the variable in order to save it?

michaelboulton commented 6 months ago

That was just an oversight, it should be possible to save values without checking the response values now in 2.9.3