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

Added test for zh_TW locale #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ def test_locale(self, mozwebqa):
else:
print "There is no language selector on the page"

@pytest.mark.nondestructive
def test_locale_zh_TW (self, mozwebqa):
main_page = MySiteHomePage(mozwebqa)
Copy link
Member

Choose a reason for hiding this comment

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

We should include a docstring to explain the test here. If I understand correctly we want to check that opening [base]/zh_TW should either stay as [base]/zh_TW or become [base]/en-US. If this is the case I would attempt to make this test a little more generic using a list of locales that this could apply to (with just one for now). I would therefore also update the name of the test to reflect this. Something like test_locales_persist_or_fallback_to_en_us.

zh_TW_locale = ['/zh-TW']
Copy link
Member

Choose a reason for hiding this comment

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

Let's call this locales and remote the leading slash.

for path in zh_TW_locale:
Copy link
Member

Choose a reason for hiding this comment

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

Make this for locale in locales:.

url = main_page.base_url + path
Copy link
Member

Choose a reason for hiding this comment

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

This could have issues if the components are not separated by a single slash. Try using urlparse.urljoin() to create the new URL.


Assert.true(url.endswith('/en-US'))
Copy link
Member

Choose a reason for hiding this comment

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

This will fail because it's testing the above variable. What we need to do is make a request based on the new URL and check that our final URL after any redirects contains either our original locale or 'en-US'. We could make this request via Selenium or something like requests.


if !url:
Copy link
Member

Choose a reason for hiding this comment

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

The correct syntax for checking a falsey value here is if not url, however this will never be the case as url is a string and therefore is truthy.

Assert.false(url.endswith('/zh-CN'))

@pytest.mark.nondestructive
def test_response_200(self, mozwebqa):
main_page = MySiteHomePage(mozwebqa)
Expand Down