Commit 450e625d by tasawernawaz

Merge pull request #10280 from edx/tasawer/story/ecom-2538-fix-for-multiple-providers

Fix parameter name issue for multiple providers
parents d414d74f 65c93d7a
...@@ -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):
......
...@@ -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_ids = request.GET.get("provider_ids", None)
providers_list = provider_id.split(",") if provider_id else None providers_list = provider_ids.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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment