Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
4e1c4c46
Commit
4e1c4c46
authored
10 years ago
by
Minh Tue Vo
Committed by
David Baumgold
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
adding tests for country list in different languages
updating the version for django_countries
parent
211a65de
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/tests/test_registration_extra_vars.py
+65
-0
65 additions, 0 deletions
...angoapps/courseware/tests/test_registration_extra_vars.py
lms/envs/common.py
+3
-0
3 additions, 0 deletions
lms/envs/common.py
with
68 additions
and
0 deletions
lms/djangoapps/courseware/tests/test_registration_extra_vars.py
+
65
−
0
View file @
4e1c4c46
...
...
@@ -7,8 +7,73 @@ from django.conf import settings
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
mock
import
patch
from
bs4
import
BeautifulSoup
from
django.utils
import
translation
class
TestSortedCountryList
(
TestCase
):
"""
Test that country list is always sorted alphabetically
"""
def
setUp
(
self
):
super
(
TestSortedCountryList
,
self
).
setUp
()
self
.
url
=
reverse
(
'
register_user
'
)
def
find_option_by_code
(
self
,
options
,
code
):
for
index
,
option
in
enumerate
(
options
):
if
option
.
attrs
[
'
value
'
]
==
code
:
return
(
index
,
option
)
@patch.dict
(
settings
.
REGISTRATION_EXTRA_FIELDS
,
{
'
country
'
:
'
required
'
})
def
test_country_sorting_english
(
self
):
"""
Test that country list is always sorted alphabetically in English
"""
response
=
self
.
client
.
get
(
self
.
url
)
soup
=
BeautifulSoup
(
response
.
content
)
country
=
soup
.
find
(
id
=
"
country
"
)
options
=
country
.
findAll
(
"
option
"
)
(
af_index
,
af_option
)
=
self
.
find_option_by_code
(
options
,
'
AF
'
)
self
.
assertEqual
(
af_option
.
text
,
u
'
Afghanistan
'
,
)
(
us_index
,
us_option
)
=
self
.
find_option_by_code
(
options
,
'
US
'
)
self
.
assertEqual
(
us_option
.
text
,
u
'
United States
'
,
)
# testing that the Afghan entry is always before the US entry
self
.
assertLess
(
af_index
,
us_index
)
# testing two option elements to be in alphabetical order
self
.
assertLess
(
options
[
1
].
text
,
options
[
10
].
text
)
@patch.dict
(
settings
.
REGISTRATION_EXTRA_FIELDS
,
{
'
country
'
:
'
required
'
})
def
test_country_sorting_french
(
self
):
"""
Test that country list is always sorted alphabetically in French
"""
user_language
=
'
fr
'
with
translation
.
override
(
user_language
):
self
.
client
.
cookies
[
'
django_language
'
]
=
user_language
response
=
self
.
client
.
get
(
self
.
url
)
soup
=
BeautifulSoup
(
response
.
content
)
country
=
soup
.
find
(
id
=
"
country
"
)
options
=
country
.
findAll
(
"
option
"
)
(
af_index
,
af_option
)
=
self
.
find_option_by_code
(
options
,
'
AF
'
)
self
.
assertEqual
(
af_option
.
text
,
u
'
Afghanistan
'
,
)
(
us_index
,
us_option
)
=
self
.
find_option_by_code
(
options
,
'
US
'
)
self
.
assertEqual
(
us_option
.
text
,
u
'
États-Unis
'
,
)
# testing that the Afghan entry is always before the US entry
self
.
assertLess
(
af_index
,
us_index
)
# testing two option elements to be in alphabetical order
self
.
assertLess
(
options
[
1
].
text
,
options
[
10
].
text
)
class
TestExtraRegistrationVariables
(
TestCase
):
"""
Test that extra registration variables are properly checked according to settings
...
...
This diff is collapsed.
Click to expand it.
lms/envs/common.py
+
3
−
0
View file @
4e1c4c46
...
...
@@ -1348,6 +1348,9 @@ INSTALLED_APPS = (
# Additional problem types
'
edx_jsme
'
,
# Molecular Structure
# Country list
'
django_countries
'
)
######################### MARKETING SITE ###############################
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment