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
572ea256
Commit
572ea256
authored
Oct 30, 2015
by
Bill DeRusha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert segment country to unicode.
parent
1804ee77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
8 deletions
+42
-8
common/djangoapps/student/tests/test_create_account.py
+41
-7
common/djangoapps/student/views.py
+1
-1
No files found.
common/djangoapps/student/tests/test_create_account.py
View file @
572ea256
"""Tests for account creation"""
from
datetime
import
datetime
import
json
import
unittest
import
ddt
import
unittest
from
django.contrib.auth.models
import
User
from
django.test.client
import
RequestFactory
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
AnonymousUser
from
django.utils.importlib
import
import_module
from
django.test
import
TestCase
,
TransactionTestCase
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
django.utils.importlib
import
import_module
import
mock
from
openedx.core.djangoapps.user_api.preferences.api
import
get_user_preference
from
lang_pref
import
LANGUAGE_KEY
from
notification_prefs
import
NOTIFICATION_PREF_KEY
from
edxmako.tests
import
mako_middleware_process_request
from
external_auth.models
import
ExternalAuthMap
import
student
...
...
@@ -115,6 +113,42 @@ class TestCreateAccount(TestCase):
"microsite_configuration.middleware.MicrositeMiddleware"
in
settings
.
MIDDLEWARE_CLASSES
,
"Microsites not implemented in this environment"
)
@override_settings
(
LMS_SEGMENT_KEY
=
"testkey"
)
@mock.patch
(
'student.views.analytics.track'
)
@mock.patch
(
'student.views.analytics.identify'
)
def
test_segment_tracking
(
self
,
mock_segment_identify
,
_
):
year
=
datetime
.
now
()
.
year
self
.
params
.
update
({
"level_of_education"
:
"a"
,
"gender"
:
"o"
,
"mailing_address"
:
"123 Example Rd"
,
"city"
:
"Exampleton"
,
"country"
:
"US"
,
"goals"
:
"To test this feature"
,
"year_of_birth"
:
str
(
year
),
"extra1"
:
"extra_value1"
,
"extra2"
:
"extra_value2"
,
})
expected_payload
=
{
'email'
:
self
.
params
[
'email'
],
'username'
:
self
.
params
[
'username'
],
'name'
:
self
.
params
[
'name'
],
'age'
:
0
,
'education'
:
'Associate degree'
,
'address'
:
self
.
params
[
'mailing_address'
],
'gender'
:
'Other/Prefer Not to Say'
,
'country'
:
self
.
params
[
'country'
],
}
self
.
create_account_and_fetch_profile
()
mock_segment_identify
.
assert_called_with
(
1
,
expected_payload
)
@unittest.skipUnless
(
"microsite_configuration.middleware.MicrositeMiddleware"
in
settings
.
MIDDLEWARE_CLASSES
,
"Microsites not implemented in this environment"
)
def
test_profile_saved_all_optional_fields
(
self
):
self
.
params
.
update
({
"level_of_education"
:
"a"
,
...
...
common/djangoapps/student/views.py
View file @
572ea256
...
...
@@ -1632,7 +1632,7 @@ def create_account_with_params(request, params):
'education'
:
profile
.
level_of_education_display
,
'address'
:
profile
.
mailing_address
,
'gender'
:
profile
.
gender_display
,
'country'
:
profile
.
country
,
'country'
:
unicode
(
profile
.
country
)
,
}
]
...
...
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