MarketSquare / robotframework-openapitools

Apache License 2.0
6 stars 1 forks source link

cleanup created data #6

Open Leemur89 opened 6 months ago

Leemur89 commented 6 months ago

Hello,

It would be nice to have a cleanup mechanism to delete all the data that has been created using the openapidriver: both when testing the POST requests and also when a data is created to test the GET/PATCH...

As an acceptable workaround, we could offer a way to get the list of all the requests made, and from there in robot I could do the cleanup (that would also offer more post processing capabilities)

Thanks

Leemur89 commented 6 months ago

for the workaround I've raised https://github.com/MarketSquare/robotframework-openapitools/pull/7

robinmackaij commented 6 months ago

I need some time to think this through. It'd indeed be nice to have a mechanic like this, but when there are dependencies between resources, simply attempting a delete isn't guaranteed to succeed.

All requests made could be extracted from the log / output.xml since Authorized Request is a keyword (so logged by default, with TRACE level logging outputting all incoming parameters and the returned value).

I think the best way to handle this is to handle it using a Listener. Using a Listener to keep track of created / altered resources has the advantage that the libraries are not affected and a Listener can easily be adapted for a specific API (where resource dependencies may apply).

It'd definitely be nice to add an example Listener implementation to the repo.

Leemur89 commented 5 months ago

Problem with listener is that you need to get the keyword results (to know the id of the object that has been created), and that is not available in RF 6. It seems that the only way to get keyword results is by using rf 7.0, this is a new feature in the listener v3 However, this openapi library does not support rf 7.0 yet :(

robinmackaij commented 5 months ago

You're right, for a Listener RF 7+ is needed and indeed, 7.0.0 is not compatible due to a breaking change that is planned to be reversed in 7.0.1 which will hopefully be released soon.