Skip to content

Refactor redirect tests #5841

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

Merged
merged 1 commit into from
Jun 25, 2019

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Jun 24, 2019

This is most like a little hack to make
the tests of the new feature in .com pass.

Why tests are passing after this changes?

First, we don't need to patch anything, by default
those files don't exist.

Now, here is the interesting part.
When a version exists (in this case 0.8.1)
the serve_docs function (from .com)
tries to verify that the current user has permissions over that
version first, this gives a 401 response.

Accessing to a unexisting version, it gives 404,
which is needed to trigger the redirect

This is most like a little hack to make
the tests of the new feature in .com pass.

Why tests are passing after this changes?

First, we don't need to patch anything, by default
those files don't exist.

Now, here is the interesting part.
When a version exists (in this case `0.8.1`)
the serve_docs function (from .com)
tries to verify that the current user has permissions over that
version first, this gives a 401 response.

Accessing to a unexisting version, it gives 404,
which is needed to trigger the redirect
@stsewd
Copy link
Member Author

stsewd commented Jun 24, 2019

oh, and the user really has permissions over that version, but it was logged in outside the new backend self.client.force_login(self.user, backend='ourcustombacken') (see test in .com)

@stsewd stsewd requested a review from a team June 24, 2019 22:13
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

Going through history, I don't see a good reason why these testss were patched to begin with. Though patching the method is much more explicit for unit tests, I think the implementation here is probably enough, it should test the same paths in theory.

It would be good to get another opinion on this though.

@stsewd stsewd requested a review from a team June 24, 2019 23:12
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This seems fine. I also don't fully understand the history, but simplification is good. 👍

@ericholscher ericholscher merged commit 0f9a646 into readthedocs:master Jun 25, 2019
@stsewd stsewd deleted the refactor-redirect-tests branch June 25, 2019 16:51
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.

3 participants