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
31a232ed
Commit
31a232ed
authored
May 13, 2015
by
jsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ecommerce-api-client and add regression test for XCOM-1606
parent
3f2c370d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
lms/djangoapps/commerce/tests/__init__.py
+34
-11
requirements/edx/github.txt
+1
-1
No files found.
lms/djangoapps/commerce/tests/__init__.py
View file @
31a232ed
# -*- coding: utf-8 -*-
""" Commerce app tests package. """
import
json
...
...
@@ -22,21 +23,25 @@ TEST_PAYMENT_DATA = {
}
@override_settings
(
ECOMMERCE_API_SIGNING_KEY
=
TEST_API_SIGNING_KEY
,
ECOMMERCE_API_URL
=
TEST_API_URL
)
class
EcommerceApiClientTest
(
TestCase
):
""" Tests to ensure the client is initialized properly. """
TEST_USER_EMAIL
=
'test@example.com'
TEST_CLIENT_ID
=
'test-client-id'
@override_settings
(
ECOMMERCE_API_SIGNING_KEY
=
TEST_API_SIGNING_KEY
,
ECOMMERCE_API_URL
=
TEST_API_URL
)
def
setUp
(
self
):
super
(
EcommerceApiClientTest
,
self
)
.
setUp
()
self
.
user
=
UserFactory
()
self
.
user
.
email
=
self
.
TEST_USER_EMAIL
self
.
user
.
save
()
# pylint: disable=no-member
@httpretty.activate
def
test_tracking_context
(
self
):
""" Ensure the tracking context is set up in the api client correctly
and automatically. """
user
=
UserFactory
()
user
.
email
=
self
.
TEST_USER_EMAIL
user
.
save
()
# pylint: disable=no-member
"""
Ensure the tracking context is set up in the api client correctly and
automatically.
"""
# fake an ecommerce api request.
httpretty
.
register_uri
(
httpretty
.
POST
,
...
...
@@ -47,17 +52,35 @@ class EcommerceApiClientTest(TestCase):
mock_tracker
=
mock
.
Mock
()
mock_tracker
.
resolve_context
=
mock
.
Mock
(
return_value
=
{
'client_id'
:
self
.
TEST_CLIENT_ID
})
with
mock
.
patch
(
'commerce.tracker.get_tracker'
,
return_value
=
mock_tracker
):
ecommerce_api_client
(
user
)
.
baskets
(
1
)
.
post
()
ecommerce_api_client
(
self
.
user
)
.
baskets
(
1
)
.
post
()
# make sure the request's JWT token payload included correct tracking context values.
actual_header
=
httpretty
.
last_request
()
.
headers
[
'Authorization'
]
expected_payload
=
{
'username'
:
user
.
username
,
'email'
:
user
.
email
,
'username'
:
self
.
user
.
username
,
'email'
:
self
.
user
.
email
,
'tracking_context'
:
{
'lms_user_id'
:
user
.
id
,
# pylint: disable=no-member
'lms_user_id'
:
self
.
user
.
id
,
# pylint: disable=no-member
'lms_client_id'
:
self
.
TEST_CLIENT_ID
,
},
}
expected_header
=
'JWT {}'
.
format
(
jwt
.
encode
(
expected_payload
,
TEST_API_SIGNING_KEY
))
self
.
assertEqual
(
actual_header
,
expected_header
)
@httpretty.activate
def
test_client_unicode
(
self
):
"""
The client should handle json responses properly when they contain
unicode character data.
Regression test for ECOM-1606.
"""
expected_content
=
'{"result": "Préparatoire"}'
httpretty
.
register_uri
(
httpretty
.
GET
,
'{}/baskets/1/order/'
.
format
(
TEST_API_URL
),
status
=
200
,
body
=
expected_content
,
adding_headers
=
{
'Content-Type'
:
'application/json'
},
)
actual_object
=
ecommerce_api_client
(
self
.
user
)
.
baskets
(
1
)
.
order
.
get
()
self
.
assertEqual
(
actual_object
,
{
u"result"
:
u"Préparatoire"
})
requirements/edx/github.txt
View file @
31a232ed
...
...
@@ -50,7 +50,7 @@ git+https://github.com/edx/edx-lint.git@8bf82a32ecb8598c415413df66f5232ab8d974e9
-e git+https://github.com/edx/xblock-utils.git@581ed636c862b286002bb9a3724cc883570eb54c#egg=xblock-utils
-e git+https://github.com/edx-solutions/xblock-google-drive.git@138e6fa0bf3a2013e904a085b9fed77dab7f3f21#egg=xblock-google-drive
-e git+https://github.com/edx/edx-reverification-block.git@2ff0d21f6614874067168bd244e68d8215041f3b#egg=edx-reverification-block
git+https://github.com/edx/ecommerce-api-client.git@0.
3.0#egg=ecommerce-api-client==0.3.0
git+https://github.com/edx/ecommerce-api-client.git@0.
4.3#egg=ecommerce-api-client==0.4.3
# Third Party XBlocks
-e git+https://github.com/mitodl/edx-sga@172a90fd2738f8142c10478356b2d9ed3e55334a#egg=edx-sga
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