wiremock / python-wiremock

A Python library for API mocking and testing with Testcontainers module and WireMock

Home Page:https://wiremock.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Server is not ready when using just `server.start()`

OlafMeuwese opened this issue · comments

Problem
The server doesn't seem to be responsive to calls when starting the server in a test or in a pytest fixture using a context (with statement).

Possible cause
The check if the server has started only checks if the process has started, but doesn't check the readiness of the server.

Proposed solution
The start function could check the readiness (using requests to retrieve a ok response) of the server before moving on, blocking the python code till the server has "actually" started.

Willing to work on this, however I wanna know if the vision on this issue is shared by the maintainers.

PR's welcome!

Based on the documentation I think we should try some simple GET requests on the admin endpoint.
The documentation states under the "Fetching all of your stub mappings (and checking WireMock is working)" section:

A GET request to the root admin URL e.g http://localhost:8080/__admin will return all currently registered stub mappings. This is a useful way to check whether WireMock is running on the host and port you expect:
(emphasis mine)

fixed and released in 2.0.0