Merge pull request #21038 from edx/INCR-384
INCR-384 python 3 compatibility
This commit is contained in:
@@ -8,6 +8,8 @@ Keep in mind that the code in this file only applies to discounts controlled in
|
||||
not other discounts like coupons or enterprise/program offers configured in ecommerce.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import crum
|
||||
|
||||
@@ -4,6 +4,8 @@ Discounts application configuration
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
"""Tests of openedx.features.discounts.applicability"""
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import timedelta, datetime
|
||||
from __future__ import absolute_import
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import ddt
|
||||
from django.utils.timezone import now
|
||||
from mock import patch, Mock
|
||||
import pytz
|
||||
from django.utils.timezone import now
|
||||
from mock import Mock, patch
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
@@ -13,11 +16,11 @@ from entitlements.tests.factories import CourseEntitlementFactory
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
|
||||
from openedx.features.discounts.models import DiscountRestrictionConfig
|
||||
from student.tests.factories import UserFactory, CourseEnrollmentFactory
|
||||
from student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
from ..applicability import can_receive_discount, DISCOUNT_APPLICABILITY_FLAG, _is_in_holdback
|
||||
from ..applicability import DISCOUNT_APPLICABILITY_FLAG, _is_in_holdback, can_receive_discount
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
"""Tests of openedx.features.discounts.views"""
|
||||
# -*- coding: utf-8 -*-
|
||||
import jwt
|
||||
from __future__ import absolute_import
|
||||
|
||||
import jwt
|
||||
import six
|
||||
from django.test.client import Client
|
||||
from django.urls import reverse
|
||||
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from student.tests.factories import TEST_PASSWORD, UserFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from student.tests.factories import UserFactory, TEST_PASSWORD
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
|
||||
class TestCourseUserDiscount(ModuleStoreTestCase):
|
||||
@@ -21,13 +23,16 @@ class TestCourseUserDiscount(ModuleStoreTestCase):
|
||||
self.user = UserFactory.create()
|
||||
self.course = CourseFactory.create(run='test', display_name='test')
|
||||
self.client = Client()
|
||||
self.url = reverse('api_discounts:course_user_discount', kwargs={'course_key_string': unicode(self.course.id)})
|
||||
self.url = reverse(
|
||||
'api_discounts:course_user_discount',
|
||||
kwargs={'course_key_string': six.text_type(self.course.id)}
|
||||
)
|
||||
|
||||
def test_url(self):
|
||||
"""
|
||||
Test that the url hasn't changed
|
||||
"""
|
||||
assert self.url == ('/api/discounts/course/' + unicode(self.course.id))
|
||||
assert self.url == ('/api/discounts/course/' + six.text_type(self.course.id))
|
||||
|
||||
def test_course_user_discount(self):
|
||||
"""
|
||||
@@ -44,7 +49,7 @@ class TestCourseUserDiscount(ModuleStoreTestCase):
|
||||
|
||||
# make sure that the response matches the expected response
|
||||
response_payload = jwt.decode(response.data['jwt'], verify=False)
|
||||
assert all(item in response_payload.items() for item in expected_payload.items())
|
||||
assert all(item in list(response_payload.items()) for item in expected_payload.items())
|
||||
|
||||
def test_course_user_discount_no_user(self):
|
||||
"""
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
Discount API URLs
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls import url
|
||||
|
||||
|
||||
@@ -4,10 +4,15 @@ The Discount API Views should return information about discounts that apply to t
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.decorators import method_decorator
|
||||
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
|
||||
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
|
||||
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.cors_csrf.decorators import ensure_csrf_cookie_cross_domain
|
||||
from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user
|
||||
@@ -15,10 +20,6 @@ from openedx.core.lib.api.authentication import OAuth2AuthenticationAllowInactiv
|
||||
from openedx.core.lib.api.permissions import ApiKeyHeaderPermissionIsAuthenticated
|
||||
from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
from django.utils.decorators import method_decorator
|
||||
|
||||
from .applicability import can_receive_discount, discount_percentage
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user