garnaat / placebo

Make boto3 calls that look real but have no effect.
Apache License 2.0
394 stars 28 forks source link

Record based on parameter hashing #78

Open RyanJarv opened 3 years ago

RyanJarv commented 3 years ago

Summary

This changes the save/load behavior from incrementing on each call to hashing the parameters and body in the API request.

So if the same request is sent and we receive different parameters it should overwrite the previous response. The exception to this is if the api call is paginated, in which case we should increment the index counter rather then overwriting.

Related

TODO

codecov-io commented 3 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (develop@1e8ab91). Click here to learn what that means. The diff coverage is 98.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop      #78   +/-   ##
==========================================
  Coverage           ?   90.10%           
==========================================
  Files              ?        4           
  Lines              ?      293           
  Branches           ?        0           
==========================================
  Hits               ?      264           
  Misses             ?       29           
  Partials           ?        0           
Impacted Files Coverage Δ
placebo/pill.py 91.84% <98.55%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1e8ab91...6a4e459. Read the comment docs.

RyanJarv commented 3 years ago

Just FYI, I might need to hard fork this soon. My use is fairly different from how this project is intended to be used, will see how it goes though.

Wanted to at least open this PR in case other people find it useful.

RyanJarv commented 3 years ago

Removing pagination support for now since this was buggy. The API's I've been testing so far don't use random markers so just including them in the hash work's out ok. Will see if I run into any issues here.

RyanJarv commented 3 years ago

Just realized I never removed the WIP label. I believe this is working.. I haven't used this in a bit though and don't have a need for it anymore.

Mentioned this above but will leave this open in case it's useful to anyone, otherwise can just be closed.

Edit: Well.. I guess works, without pagination. Or something like that.