Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add delay before response #12

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lucsorel
Copy link

@lucsorel lucsorel commented Jan 24, 2025

hello @amaziahub, thank you for the mimicker project 🙏

Here is a pull request to add the route.delay(duration) optional feature to make a matched stub delay before returning the response. This feature allows to test how the code (calling a mimicked web API) reacts to a connection timeout.

I added:

  • some documentation in the README.md file
  • some unit tests about the route definition and to check that the mimicker server actually waits when asked to

This feature and the tests are included in the same commit. Other commits are suggestions that can be reverted if you like:

  • I moved requests in the dev dependencies because it is not used in the production code: it thus won't be installed in the codebases using mimicker (requests can conflict with other web clients like niquests or httpx)
  • I made mimicker able to run several times in a row so that tests can be run multiple times
  • I created a namedtuple class to model a Stub to increase code legibility and add type annotations in the code

Also, the first commit was necessary to fix some syntax errors in an f-string.

I tried to follow the code standards of the project and I used hamcrest in the unit tests (thanks for the discovery), I hope you will appreciate this contribution. Thank you again for mimicker 🙂

@lucsorel lucsorel force-pushed the feat/add-delay-before-response branch from 03f4f0a to 81ae1c5 Compare January 24, 2025 14:19
@lucsorel lucsorel force-pushed the feat/add-delay-before-response branch from 81ae1c5 to ada957a Compare January 24, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant