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

Router rollback settings #186

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Mojken
Copy link

@Mojken Mojken commented Nov 11, 2021

Adds router settings to the rollback functionality, as well as a function configure() which allows changing the settings of the router, creating a new snapshot.

Closes #181

Adds a function to allow changing of settings on a per-snapshot basis
@lundberg
Copy link
Owner

Thanks for the PR @Mojken.

I also gave this a try but got stuck on the bases.

The intention of this requested configuration feature is for example to be able to change base_url, and in turn bases, for a router.

Changing the bases like you do will work, but only apply for new added routes, if any existing routes is present on the router when re-configuring the base_url, the existing routes will still have the old bases merged to their pattern.

@Mojken
Copy link
Author

Mojken commented Nov 11, 2021

That sounds like expected behaviour to me. I wouldn't expect things I've set up before to be changed as a side-effect of me changing the configuration of the router. It doesn't seem like a very difficult thing to fix, perhaps adding a method to update old routes is a reasonable next step?

@flaeppe
Copy link
Contributor

flaeppe commented Nov 12, 2021

I wouldn't expect things I've set up before to be changed as a side-effect of me changing the configuration of the router.

Actually I would. At least when standing on the outside looking in. Since it isn't really revealed that bases are merged together with routes to form and "freeze" a pattern.

e.g.

import respx
mocker = respx.mock(base_url="http://localhost/")
mocker.get("some/path")
other_mocker = mocker(base_url="http://some.where/")
# After doing this, my initial assumption would be that 'other_mocker' is now capturing the following request
import httpx
with other_mocker:
    httpx.Client().get("http://some.where/some/path")

Just wanted to clarify what kind of behaviour I'm interested in, the snippet above should resemble my use case

@Farik1972
Copy link

Adds router settings to the rollback functionality, as well as a function configure() which allows changing the settings of the router, creating a new snapshot.

Closes #181

19f2e24c41a475a1b20e334c2064647203f3cd22

Copy link

@Farik1972 Farik1972 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • [ ]

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.

Allow reusing settings from a MockRouter instance on MockRouter.__call__
4 participants