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
6e9c2d33
Commit
6e9c2d33
authored
Mar 02, 2017
by
Ayub-Khan
Committed by
Simon Chen
Mar 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-Updated the Oauth access token for enrolment check
-fixed failing tests
parent
c6000520
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
ecommerce/core/models.py
+3
-3
ecommerce/core/tests/test_models.py
+1
-0
ecommerce/extensions/basket/tests/test_views.py
+6
-2
No files found.
ecommerce/core/models.py
View file @
6e9c2d33
...
@@ -17,7 +17,7 @@ from django.utils.translation import ugettext_lazy as _
...
@@ -17,7 +17,7 @@ from django.utils.translation import ugettext_lazy as _
from
edx_rest_api_client.client
import
EdxRestApiClient
from
edx_rest_api_client.client
import
EdxRestApiClient
from
jsonfield.fields
import
JSONField
from
jsonfield.fields
import
JSONField
from
requests.exceptions
import
ConnectionError
,
Timeout
from
requests.exceptions
import
ConnectionError
,
Timeout
from
slumber.exceptions
import
HttpNotFoundError
,
SlumberBaseException
from
slumber.exceptions
import
HttpNotFoundError
,
SlumberBaseException
,
HttpClientError
from
ecommerce.core.exceptions
import
VerificationStatusError
from
ecommerce.core.exceptions
import
VerificationStatusError
from
ecommerce.core.url_utils
import
get_lms_url
from
ecommerce.core.url_utils
import
get_lms_url
...
@@ -434,11 +434,11 @@ class User(AbstractUser):
...
@@ -434,11 +434,11 @@ class User(AbstractUser):
try
:
try
:
api
=
EdxRestApiClient
(
api
=
EdxRestApiClient
(
request
.
site
.
siteconfiguration
.
build_lms_url
(
'/api/enrollment/v1'
),
request
.
site
.
siteconfiguration
.
build_lms_url
(
'/api/enrollment/v1'
),
oauth_access_token
=
self
.
access_token
,
jwt
=
request
.
site
.
siteconfiguration
.
access_token
,
append_slash
=
False
append_slash
=
False
)
)
status
=
api
.
enrollment
(
','
.
join
([
self
.
username
,
course_key
]))
.
get
()
status
=
api
.
enrollment
(
','
.
join
([
self
.
username
,
course_key
]))
.
get
()
except
(
ConnectionError
,
SlumberBaseException
,
Timeout
):
except
(
ConnectionError
,
SlumberBaseException
,
Timeout
,
HttpClientError
):
log
.
exception
(
log
.
exception
(
'Failed to retrieve enrollment details for [
%
s] in course [
%
s]'
,
'Failed to retrieve enrollment details for [
%
s] in course [
%
s]'
,
self
.
username
,
self
.
username
,
...
...
ecommerce/core/tests/test_models.py
View file @
6e9c2d33
...
@@ -78,6 +78,7 @@ class UserTests(CourseCatalogTestMixin, LmsApiMockMixin, TestCase):
...
@@ -78,6 +78,7 @@ class UserTests(CourseCatalogTestMixin, LmsApiMockMixin, TestCase):
""" Verify check for user enrollment in a course. """
""" Verify check for user enrollment in a course. """
user
=
self
.
create_user
()
user
=
self
.
create_user
()
self
.
request
.
user
=
user
self
.
request
.
user
=
user
self
.
mock_access_token_response
()
course_id1
=
'course-v1:test+test+test'
course_id1
=
'course-v1:test+test+test'
__
,
enrolled_seat
=
self
.
create_course_and_seat
(
__
,
enrolled_seat
=
self
.
create_course_and_seat
(
course_id
=
course_id1
,
seat_type
=
mode
,
id_verification
=
id_verification
course_id
=
course_id1
,
seat_type
=
mode
,
id_verification
=
id_verification
...
...
ecommerce/extensions/basket/tests/test_views.py
View file @
6e9c2d33
...
@@ -37,7 +37,7 @@ from ecommerce.extensions.payment.forms import PaymentForm
...
@@ -37,7 +37,7 @@ from ecommerce.extensions.payment.forms import PaymentForm
from
ecommerce.extensions.payment.tests.processors
import
DummyProcessor
from
ecommerce.extensions.payment.tests.processors
import
DummyProcessor
from
ecommerce.extensions.test.factories
import
prepare_voucher
from
ecommerce.extensions.test.factories
import
prepare_voucher
from
ecommerce.tests.factories
import
StockRecordFactory
from
ecommerce.tests.factories
import
StockRecordFactory
from
ecommerce.tests.mixins
import
ApiMockMixin
,
LmsApiMockMixin
from
ecommerce.tests.mixins
import
ApiMockMixin
,
LmsApiMockMixin
,
SiteMixin
from
ecommerce.tests.testcases
import
TestCase
from
ecommerce.tests.testcases
import
TestCase
Applicator
=
get_class
(
'offer.utils'
,
'Applicator'
)
Applicator
=
get_class
(
'offer.utils'
,
'Applicator'
)
...
@@ -57,7 +57,8 @@ COUPON_CODE = 'COUPONTEST'
...
@@ -57,7 +57,8 @@ COUPON_CODE = 'COUPONTEST'
@ddt.ddt
@ddt.ddt
class
BasketSingleItemViewTests
(
CouponMixin
,
CourseCatalogTestMixin
,
CourseCatalogMockMixin
,
LmsApiMockMixin
,
TestCase
):
class
BasketSingleItemViewTests
(
CouponMixin
,
CourseCatalogTestMixin
,
CourseCatalogMockMixin
,
LmsApiMockMixin
,
TestCase
,
SiteMixin
):
""" BasketSingleItemView view tests. """
""" BasketSingleItemView view tests. """
path
=
reverse
(
'basket:single-item'
)
path
=
reverse
(
'basket:single-item'
)
...
@@ -143,6 +144,7 @@ class BasketSingleItemViewTests(CouponMixin, CourseCatalogTestMixin, CourseCatal
...
@@ -143,6 +144,7 @@ class BasketSingleItemViewTests(CouponMixin, CourseCatalogTestMixin, CourseCatal
Verify the view redirects to the basket summary page, and that the user's basket is prepared for checkout.
Verify the view redirects to the basket summary page, and that the user's basket is prepared for checkout.
"""
"""
self
.
mock_enrollment_api_success_enrolled
(
self
.
course
.
id
)
self
.
mock_enrollment_api_success_enrolled
(
self
.
course
.
id
)
self
.
mock_access_token_response
()
self
.
create_coupon
(
catalog
=
self
.
catalog
,
code
=
COUPON_CODE
,
benefit_value
=
5
)
self
.
create_coupon
(
catalog
=
self
.
catalog
,
code
=
COUPON_CODE
,
benefit_value
=
5
)
self
.
mock_dynamic_catalog_course_runs_api
(
course_run
=
self
.
course
)
self
.
mock_dynamic_catalog_course_runs_api
(
course_run
=
self
.
course
)
...
@@ -167,6 +169,7 @@ class BasketSingleItemViewTests(CouponMixin, CourseCatalogTestMixin, CourseCatal
...
@@ -167,6 +169,7 @@ class BasketSingleItemViewTests(CouponMixin, CourseCatalogTestMixin, CourseCatal
(The Enrollment API call being used returns an active enrollment record in this case)
(The Enrollment API call being used returns an active enrollment record in this case)
"""
"""
course
=
CourseFactory
()
course
=
CourseFactory
()
self
.
mock_access_token_response
()
self
.
mock_enrollment_api_success_enrolled
(
course
.
id
,
mode
=
mode
)
self
.
mock_enrollment_api_success_enrolled
(
course
.
id
,
mode
=
mode
)
product
=
course
.
create_or_update_seat
(
mode
,
id_verification
,
0
,
self
.
partner
,
create_enrollment_code
=
False
)
product
=
course
.
create_or_update_seat
(
mode
,
id_verification
,
0
,
self
.
partner
,
create_enrollment_code
=
False
)
stock_record
=
StockRecordFactory
(
product
=
product
,
partner
=
self
.
partner
)
stock_record
=
StockRecordFactory
(
product
=
product
,
partner
=
self
.
partner
)
...
@@ -188,6 +191,7 @@ class BasketSingleItemViewTests(CouponMixin, CourseCatalogTestMixin, CourseCatal
...
@@ -188,6 +191,7 @@ class BasketSingleItemViewTests(CouponMixin, CourseCatalogTestMixin, CourseCatal
(The Enrollment API call being used returns an inactive enrollment record in this case)
(The Enrollment API call being used returns an inactive enrollment record in this case)
"""
"""
course
=
CourseFactory
()
course
=
CourseFactory
()
self
.
mock_access_token_response
()
self
.
mock_enrollment_api_success_unenrolled
(
course
.
id
,
mode
=
mode
)
self
.
mock_enrollment_api_success_unenrolled
(
course
.
id
,
mode
=
mode
)
product
=
course
.
create_or_update_seat
(
mode
,
id_verification
,
0
,
self
.
partner
)
product
=
course
.
create_or_update_seat
(
mode
,
id_verification
,
0
,
self
.
partner
)
stock_record
=
StockRecordFactory
(
product
=
product
,
partner
=
self
.
partner
)
stock_record
=
StockRecordFactory
(
product
=
product
,
partner
=
self
.
partner
)
...
...
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