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

Consider a router option to define default response #227

Open
lundberg opened this issue Jan 27, 2023 · 0 comments
Open

Consider a router option to define default response #227

lundberg opened this issue Jan 27, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@lundberg
Copy link
Owner

As discussed in #177 (comment) .

By default, respx responds with a httpx.Resopnse(200) when no mocked route is matched and assert_all_mocked is disabled.

The idea is to allow the router to take a default mock option to override that.

e.g.

mock_api = respx.mock(base_url="https://example.com/", default_mock=httpx.Response(404))

@mock_api
def test_example():
    response = httpx.get("https://example.com/some/path/")
    assert response.status_code == 404

By setting this option, assert_all_mocked should probably be forced disabled.

@lundberg lundberg added the enhancement New feature or request label Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant