Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

bug 1461350: Update Middleware tests #4778

Merged
merged 4 commits into from
May 14, 2018

Conversation

jwhitlock
Copy link
Contributor

In preparation to update the locale infrastructure, expand tests for middleware and other components, and convert to pytest style:

  • LocaleURLMiddleware
    • Convert tests to pytest.
    • Test Accept-Language header variations from get_best_language
    • Add more ?lang scenarios
    • Add legacy locale redirect tests
    • Add non-locale 404 tests
  • RemoveSlashMiddleware - Convert tests to pytest. The test cases actually exercise the mindtouch_to_kuma_redirect view, and the middleware code never runs. The next PR will update the test cases and fix the functionality.
  • SetRemoteAddrFromForwardedFor - Convert tests to pytest.

This was originally part of PR #4766, but has been split out to confirm that tests pass with LocaleURLMiddleware before replacing it.

Convert LocaleURLMiddlware and get_best_language tests to pytest style,
and share the get_best_language test cases with the LocaleURLMiddlware
tests, since get_best_language won't be needed after the Django 1.11
transition.
Add tests for MDN-specific locale fixes, such as cn → zh-CN, and for
legacy URLs that should 404, such as index.php. These were previously
tested only in headless tests, but are part of the URL contract.
Test ?lang redirects for the root URL, the English homepage, and when
the parameter is the same as the current locale.
Convert the remaining middleware tests (RemoveSlashMiddleware,
SetRemoteAddrFromForwardedFor) to pytest.
@jwhitlock jwhitlock requested a review from escattone May 14, 2018 21:55
Copy link
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

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

Thanks @jwhitlock!

@escattone escattone merged commit df5bc3b into mdn:master May 14, 2018
@jwhitlock jwhitlock deleted the middleware-tests-1461350 branch May 16, 2018 15:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants