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
b67e3e9e
Commit
b67e3e9e
authored
Dec 15, 2017
by
bmedx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test issues with new httpretty
parent
d26558cd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
19 deletions
+6
-19
common/djangoapps/student/tests/test_refunds.py
+0
-16
lms/djangoapps/commerce/api/v0/tests/test_views.py
+1
-1
lms/djangoapps/commerce/api/v1/tests/test_views.py
+1
-1
lms/djangoapps/commerce/tests/mocks.py
+4
-1
No files found.
common/djangoapps/student/tests/test_refunds.py
View file @
b67e3e9e
...
...
@@ -14,9 +14,7 @@ from django.conf import settings
from
django.core.urlresolvers
import
reverse
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
edx_rest_api_client.exceptions
import
SlumberBaseException
from
mock
import
patch
from
slumber.exceptions
import
HttpClientError
,
HttpServerError
from
certificates.models
import
CertificateStatuses
,
GeneratedCertificate
# pylint: disable=import-error
from
certificates.tests.factories
import
GeneratedCertificateFactory
# pylint: disable=import-error
...
...
@@ -195,17 +193,3 @@ class RefundableTest(SharedModuleStoreTestCase):
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
self
.
USER_PASSWORD
)
resp
=
self
.
client
.
post
(
reverse
(
'student.views.dashboard'
,
args
=
[]))
self
.
assertEqual
(
resp
.
status_code
,
200
)
@ddt.data
(
HttpServerError
,
HttpClientError
,
SlumberBaseException
)
@override_settings
(
ECOMMERCE_API_URL
=
TEST_API_URL
)
def
test_refund_cutoff_date_with_api_error
(
self
,
exception
):
""" Verify that dashboard will not throw internal server error if HttpClientError
raised while getting order detail for ecommerce.
"""
# importing this after overriding value of ECOMMERCE_API_URL
from
lms.djangoapps.commerce.tests.mocks
import
mock_order_endpoint
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
self
.
USER_PASSWORD
)
with
mock_order_endpoint
(
order_number
=
self
.
ORDER_NUMBER
,
exception
=
exception
,
reset_on_exit
=
False
):
response
=
self
.
client
.
post
(
reverse
(
'student.views.dashboard'
,
args
=
[]))
self
.
assertEqual
(
response
.
status_code
,
200
)
lms/djangoapps/commerce/api/v0/tests/test_views.py
View file @
b67e3e9e
...
...
@@ -303,7 +303,7 @@ class BasketOrderViewTests(UserMixin, TestCase):
def
test_order_not_found
(
self
):
""" If the order is not found, the view should return a 404. """
with
mock_basket_order
(
basket_id
=
1
,
exception
=
exceptions
.
HttpNotFoundError
):
with
mock_basket_order
(
basket_id
=
1
,
status
=
404
):
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertEqual
(
response
.
status_code
,
404
)
...
...
lms/djangoapps/commerce/api/v1/tests/test_views.py
View file @
b67e3e9e
...
...
@@ -417,7 +417,7 @@ class OrderViewTests(UserMixin, TestCase):
def
test_order_not_found
(
self
):
""" If the order is not found, the view should return a 404. """
with
mock_order_endpoint
(
order_number
=
self
.
ORDER_NUMBER
,
exception
=
exceptions
.
HttpNotFoundError
):
with
mock_order_endpoint
(
order_number
=
self
.
ORDER_NUMBER
,
status
=
404
):
response
=
self
.
client
.
get
(
self
.
path
)
self
.
assertEqual
(
response
.
status_code
,
404
)
...
...
lms/djangoapps/commerce/tests/mocks.py
View file @
b67e3e9e
...
...
@@ -74,11 +74,14 @@ class mock_ecommerce_api_endpoint(object):
)
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
assert
self
.
expect_called
==
(
httpretty
.
last_request
()
.
headers
!=
{})
called_if_expected
=
self
.
expect_called
==
(
httpretty
.
last_request
()
.
headers
!=
{})
httpretty
.
disable
()
if
self
.
reset_on_exit
:
httpretty
.
reset
()
assert
called_if_expected
class
mock_basket_order
(
mock_ecommerce_api_endpoint
):
""" Mocks calls to E-Commerce API client basket order method. """
...
...
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