Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
9484fe52
Commit
9484fe52
authored
May 03, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #82 from edx/clintonb/psa-update
Removed pinned version of python-social-auth
parents
17653c90
8ea946b1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
24 deletions
+28
-24
Makefile
+2
-2
course_discovery/apps/core/models.py
+6
-4
course_discovery/apps/core/tests/test_models.py
+19
-15
requirements/base.txt
+1
-2
requirements/test.txt
+0
-1
No files found.
Makefile
View file @
9484fe52
...
...
@@ -39,10 +39,10 @@ clean: clean_static
coverage erase
requirements
:
pip install
-
q
r
requirements/local.txt
--exists-action
w
pip install
-r
requirements/local.txt
--exists-action
w
production-requirements
:
pip install
-
q
r
requirements.txt
--exists-action
w
pip install
-r
requirements.txt
--exists-action
w
test
:
clean
coverage run ./manage.py
test
course_discovery
--settings
=
course_discovery.settings.test
...
...
course_discovery/apps/core/models.py
View file @
9484fe52
...
...
@@ -16,10 +16,12 @@ class User(GuardianUserMixin, AbstractUser):
Assumes user has authenticated at least once with edX Open ID Connect.
"""
try
:
return
self
.
social_auth
.
first
()
.
extra_data
[
u'access_token'
]
# pylint: disable=no-member
except
Exception
:
# pylint: disable=broad-except
return
None
social_auth
=
self
.
social_auth
.
first
()
# pylint: disable=no-member
if
social_auth
:
return
social_auth
.
access_token
return
None
class
Meta
(
object
):
# pylint:disable=missing-docstring
get_latest_by
=
'date_joined'
...
...
course_discovery/apps/core/tests/test_models.py
View file @
9484fe52
""" Tests for core models. """
from
django.test
import
TestCase
from
django_dynamic_fixture
import
G
from
social.apps.django_app.default.models
import
UserSocialAuth
from
course_discovery.apps.core.models
import
User
,
Currency
from
course_discovery.apps.core.models
import
Currency
from
course_discovery.apps.core.tests.factories
import
UserFactory
# pylint: disable=no-member
class
UserTests
(
TestCase
):
""" User model tests. """
TEST_CONTEXT
=
{
'foo'
:
'bar'
,
'baz'
:
None
}
def
test_access_token
(
self
):
user
=
G
(
User
)
self
.
assertIsNone
(
user
.
access_token
)
def
setUp
(
self
):
super
(
UserTests
,
self
)
.
setUp
()
self
.
user
=
UserFactory
()
def
test_access_token_without_social_auth
(
self
):
""" Verify the property returns None if the user is not associated with a UserSocialAuth. """
self
.
assertIsNone
(
self
.
user
.
access_token
)
social_auth
=
G
(
UserSocialAuth
,
user
=
user
)
self
.
assertIsNone
(
user
.
access_token
)
def
test_access_token
(
self
):
""" Verify the property returns the value of the access_token stored with the UserSocialAuth. """
social_auth
=
UserSocialAuth
.
objects
.
create
(
user
=
self
.
user
,
provider
=
'test'
,
uid
=
self
.
user
.
username
)
self
.
assertIsNone
(
self
.
user
.
access_token
)
access_token
=
u
'My voice is my passport. Verify me.'
social_auth
.
extra_data
[
u'access_token'
]
=
access_token
access_token
=
'My voice is my passport. Verify me.'
social_auth
.
extra_data
.
update
({
'access_token'
:
access_token
})
social_auth
.
save
()
self
.
assertEqual
(
user
.
access_token
,
access_token
)
self
.
assertEqual
(
self
.
user
.
access_token
,
access_token
)
def
test_get_full_name
(
self
):
""" Test that the user model concatenates first and last name if the full name is not set. """
full_name
=
"George Costanza"
user
=
G
(
User
,
full_name
=
full_name
)
user
=
UserFactory
(
full_name
=
full_name
)
self
.
assertEqual
(
user
.
get_full_name
(),
full_name
)
first_name
=
"Jerry"
last_name
=
"Seinfeld"
user
=
G
(
User
,
full_name
=
None
,
first_name
=
first_name
,
last_name
=
last_name
)
user
=
UserFactory
(
full_name
=
None
,
first_name
=
first_name
,
last_name
=
last_name
)
expected
=
"{first_name} {last_name}"
.
format
(
first_name
=
first_name
,
last_name
=
last_name
)
self
.
assertEqual
(
user
.
get_full_name
(),
expected
)
user
=
G
(
User
,
full_name
=
full_name
,
first_name
=
first_name
,
last_name
=
last_name
)
user
=
UserFactory
(
full_name
=
full_name
,
first_name
=
first_name
,
last_name
=
last_name
)
self
.
assertEqual
(
user
.
get_full_name
(),
full_name
)
...
...
requirements/base.txt
View file @
9484fe52
...
...
@@ -10,7 +10,7 @@ djangorestframework==3.3.3
djangorestframework-jwt==1.7.2
django-rest-swagger[reST]==0.3.5
dry-rest-permissions==0.1.6
edx-auth-backends==0.2.
1
edx-auth-backends==0.2.
3
edx-ccx-keys==0.2.0
edx-drf-extensions==0.5.0
edx-opaque-keys==0.3.0
...
...
@@ -19,5 +19,4 @@ elasticsearch>=1.0.0,<2.0.0
html2text==2016.4.2
pycountry==1.20
python-dateutil==2.5.2
python-social-auth==0.2.14
pytz==2015.7
requirements/test.txt
View file @
9484fe52
...
...
@@ -3,7 +3,6 @@
coverage==4.0.2
ddt==1.0.1
django-dynamic-fixture==1.8.5
django-nose==1.4.2
edx-lint==0.5.0
factory-boy==2.6.0
...
...
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