Python-modernize on edx-platform (338 of 380)
After executing python-modernize and isort, few changes occurred in import sequence as well as unicode func is replaced by six.text_type func. INCR-441
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
API URLs.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import include, url
|
||||
|
||||
app_name = 'commerce'
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
""" Commerce API v0 view tests. """
|
||||
from __future__ import absolute_import
|
||||
|
||||
import itertools
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
@@ -7,10 +9,11 @@ from uuid import uuid4
|
||||
import ddt
|
||||
import mock
|
||||
import pytz
|
||||
import six
|
||||
from django.conf import settings
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse, reverse_lazy
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
@@ -50,7 +53,7 @@ class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase)
|
||||
:return: Response
|
||||
"""
|
||||
payload = {
|
||||
"course_id": unicode(course_id or self.course.id)
|
||||
"course_id": six.text_type(course_id or self.course.id)
|
||||
}
|
||||
if marketing_email_opt_in:
|
||||
payload["email_opt_in"] = True
|
||||
@@ -249,7 +252,7 @@ class BasketsViewTests(EnrollmentEventTestMixin, UserMixin, ModuleStoreTestCase)
|
||||
CourseEnrollment.enroll(self.user, self.course.id)
|
||||
CourseEnrollment.unenroll(self.user, self.course.id, True)
|
||||
self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course.id))
|
||||
self.assertIsNotNone(get_enrollment(self.user.username, unicode(self.course.id)))
|
||||
self.assertIsNotNone(get_enrollment(self.user.username, six.text_type(self.course.id)))
|
||||
|
||||
@mock.patch('lms.djangoapps.commerce.api.v0.views.update_email_opt_in')
|
||||
@ddt.data(*itertools.product((False, True), (False, True), (False, True)))
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
API v0 URLs.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf.urls import include, url
|
||||
|
||||
from . import views
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
""" API v0 views. """
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
import six
|
||||
from django.urls import reverse
|
||||
from edx_rest_api_client import exceptions
|
||||
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
|
||||
from rest_framework.authentication import SessionAuthentication
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.status import HTTP_406_NOT_ACCEPTABLE, HTTP_409_CONFLICT
|
||||
@@ -67,7 +70,7 @@ class BasketsView(APIView):
|
||||
|
||||
def _enroll(self, course_key, user, mode=CourseMode.DEFAULT_MODE_SLUG):
|
||||
""" Enroll the user in the course. """
|
||||
add_enrollment(user.username, unicode(course_key), mode)
|
||||
add_enrollment(user.username, six.text_type(course_key), mode)
|
||||
|
||||
def _handle_marketing_opt_in(self, request, course_key, user):
|
||||
"""
|
||||
@@ -100,7 +103,7 @@ class BasketsView(APIView):
|
||||
return embargo_response
|
||||
|
||||
# Don't do anything if an enrollment already exists
|
||||
course_id = unicode(course_key)
|
||||
course_id = six.text_type(course_key)
|
||||
enrollment = CourseEnrollment.get_enrollment(user, course_key)
|
||||
if enrollment and enrollment.is_active:
|
||||
msg = Messages.ENROLLMENT_EXISTS.format(course_id=course_id, username=user.username)
|
||||
@@ -123,7 +126,7 @@ class BasketsView(APIView):
|
||||
if CourseEntitlement.check_for_existing_entitlement_and_enroll(user=user, course_run_key=course_key):
|
||||
return JsonResponse(
|
||||
{
|
||||
'redirect_destination': reverse('courseware', args=[unicode(course_id)]),
|
||||
'redirect_destination': reverse('courseware', args=[six.text_type(course_id)]),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user