Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
122f0808
Commit
122f0808
authored
Feb 03, 2017
by
Ivan Ivic
Committed by
Ivan Ivic
Feb 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get account details with site configuration
access token instead of user access token SOL-2163
parent
167cae80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
+12
-1
ecommerce/core/models.py
+1
-1
ecommerce/core/tests/test_models.py
+11
-0
No files found.
ecommerce/core/models.py
View file @
122f0808
...
@@ -425,7 +425,7 @@ class User(AbstractUser):
...
@@ -425,7 +425,7 @@ class User(AbstractUser):
try
:
try
:
api
=
EdxRestApiClient
(
api
=
EdxRestApiClient
(
request
.
site
.
siteconfiguration
.
build_lms_url
(
'/api/user/v1'
),
request
.
site
.
siteconfiguration
.
build_lms_url
(
'/api/user/v1'
),
oauth_access_token
=
self
.
access_token
,
jwt
=
request
.
site
.
siteconfiguration
.
access_token
,
append_slash
=
False
append_slash
=
False
)
)
response
=
api
.
accounts
(
self
.
username
)
.
get
()
response
=
api
.
accounts
(
self
.
username
)
.
get
()
...
...
ecommerce/core/tests/test_models.py
View file @
122f0808
...
@@ -98,6 +98,17 @@ class UserTests(CourseCatalogTestMixin, LmsApiMockMixin, TestCase):
...
@@ -98,6 +98,17 @@ class UserTests(CourseCatalogTestMixin, LmsApiMockMixin, TestCase):
self
.
mock_account_api
(
self
.
request
,
user
.
username
,
data
=
user_details
)
self
.
mock_account_api
(
self
.
request
,
user
.
username
,
data
=
user_details
)
self
.
assertDictEqual
(
user
.
account_details
(
self
.
request
),
user_details
)
self
.
assertDictEqual
(
user
.
account_details
(
self
.
request
),
user_details
)
def
test_user_details_uses_jwt
(
self
):
"""Verify user_details uses jwt from site configuration to call EdxRestApiClient."""
user
=
self
.
create_user
()
with
mock
.
patch
(
"ecommerce.core.models.EdxRestApiClient"
)
as
patched_info
:
user
.
account_details
(
self
.
request
)
patched_info
.
assert_called_once_with
(
self
.
request
.
site
.
siteconfiguration
.
build_lms_url
(
'/api/user/v1'
),
append_slash
=
False
,
jwt
=
self
.
request
.
site
.
siteconfiguration
.
access_token
)
def
test_no_user_details
(
self
):
def
test_no_user_details
(
self
):
""" Verify False is returned when there is a connection error. """
""" Verify False is returned when there is a connection error. """
user
=
self
.
create_user
()
user
=
self
.
create_user
()
...
...
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