neoclient / neoclient

:rocket: Fast API Clients for Python
https://pypi.org/project/neoclient/
MIT License
1 stars 0 forks source link

:sparkles: Support Mocking for Testing #47

Open tombulled opened 1 year ago

tombulled commented 1 year ago

Ensure neoclient-created clients can be easily mocked for integration tests. E.g. by implementing a MockNeoClient.

Note: Can supply httpx.Client an app! (WSGI/ASGI)

If this is the case, perhaps a real NeoClient instance should be used against a mock server?

Assuming a mock client was to be made, it would likely work a bit like this:

from neoclient import MockNeoClient

client = MockNeoClient()

@client.get("/greet")
def greet(name: str) -> dict:
    return {"message": name}

In this event, no composition or resolution ever happens. But how would you test middleware etc. :/

Maybe the user must specify their own fake client, which implements the Client interface ((Request, /) -> Response).

tombulled commented 1 year ago

Provide test utilities from a separate neoclient-test library?