Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
4e1c4c46
Commit
4e1c4c46
authored
Aug 19, 2014
by
Minh Tue Vo
Committed by
David Baumgold
Aug 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding tests for country list in different languages
updating the version for django_countries
parent
211a65de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
lms/djangoapps/courseware/tests/test_registration_extra_vars.py
+65
-0
lms/envs/common.py
+3
-0
No files found.
lms/djangoapps/courseware/tests/test_registration_extra_vars.py
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
...
...
lms/envs/common.py
View file @
4e1c4c46
...
...
@@ -1348,6 +1348,9 @@ INSTALLED_APPS = (
# Additional problem types
'edx_jsme'
,
# Molecular Structure
# Country list
'django_countries'
)
######################### MARKETING SITE ###############################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment