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
450e625d
Commit
450e625d
authored
Oct 22, 2015
by
tasawernawaz
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10280 from edx/tasawer/story/ecom-2538-fix-for-multiple-providers
Fix parameter name issue for multiple providers
parents
d414d74f
65c93d7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
openedx/core/djangoapps/credit/tests/test_views.py
+45
-0
openedx/core/djangoapps/credit/views.py
+2
-2
No files found.
openedx/core/djangoapps/credit/tests/test_views.py
View file @
450e625d
...
@@ -336,6 +336,51 @@ class CreditProviderViewTests(UrlResetMixin, TestCase):
...
@@ -336,6 +336,51 @@ class CreditProviderViewTests(UrlResetMixin, TestCase):
request
=
CreditRequest
.
objects
.
get
(
uuid
=
uuid
)
request
=
CreditRequest
.
objects
.
get
(
uuid
=
uuid
)
self
.
assertEqual
(
request
.
status
,
expected_status
)
self
.
assertEqual
(
request
.
status
,
expected_status
)
def
test_get_providers_detail
(
self
):
"""Verify that the method 'get_provider_detail' returns provider with
the given provide in 'provider_ids'.
"""
url
=
reverse
(
"credit:providers_detail"
)
+
"?provider_ids=hogwarts"
response
=
self
.
client
.
get
(
url
)
expected
=
[
{
'enable_integration'
:
True
,
'description'
:
''
,
'url'
:
'https://credit.example.com/request'
,
'status_url'
:
''
,
'thumbnail_url'
:
''
,
'fulfillment_instructions'
:
None
,
'display_name'
:
''
,
'id'
:
'hogwarts'
}
]
self
.
assertListEqual
(
json
.
loads
(
response
.
content
),
expected
)
def
test_get_providers_with_multiple_provider_ids
(
self
):
"""Test that the method 'get_provider_detail' returns multiple
providers with given 'provider_ids' or when no provider in
'provider_ids' is given.
"""
# Add another credit provider for the course
CreditProvider
.
objects
.
create
(
provider_id
=
'dummy_id'
,
enable_integration
=
True
,
provider_url
=
'https://example.com'
,
)
# verify that all the matching providers are returned when provider ids
# are given in parameter 'provider_ids'
url
=
reverse
(
"credit:providers_detail"
)
+
"?provider_ids=hogwarts,dummy_id"
response
=
self
.
client
.
get
(
url
)
self
.
assertEquals
(
len
(
json
.
loads
(
response
.
content
)),
2
)
# verify that all providers are returned when no provider id in
# parameter 'provider_ids' is provided
url
=
reverse
(
"credit:providers_detail"
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEquals
(
len
(
json
.
loads
(
response
.
content
)),
2
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
CreditCourseViewSetTests
(
TestCase
):
class
CreditCourseViewSetTests
(
TestCase
):
...
...
openedx/core/djangoapps/credit/views.py
View file @
450e625d
...
@@ -74,8 +74,8 @@ def get_providers_detail(request):
...
@@ -74,8 +74,8 @@ def get_providers_detail(request):
* 404 Not Found: The provider does not exist.
* 404 Not Found: The provider does not exist.
"""
"""
provider_id
=
request
.
GET
.
get
(
"provider_id
"
,
None
)
provider_id
s
=
request
.
GET
.
get
(
"provider_ids
"
,
None
)
providers_list
=
provider_id
.
split
(
","
)
if
provider_id
else
None
providers_list
=
provider_id
s
.
split
(
","
)
if
provider_ids
else
None
providers
=
api
.
get_credit_providers
(
providers_list
)
providers
=
api
.
get_credit_providers
(
providers_list
)
return
JsonResponse
(
providers
)
return
JsonResponse
(
providers
)
...
...
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