Run python-modernize on openedx/features/course_experience/views and openedx/features/course_experience/tests
This commit is contained in:
Ana Maria Rodriguez
2019-04-24 13:52:53 -05:00
parent bf661eaa8d
commit d2f7acf29c
16 changed files with 104 additions and 58 deletions

View File

@@ -1,6 +1,8 @@
"""
Test helpers for the course experience.
"""
from __future__ import absolute_import
from datetime import timedelta
from django.core.exceptions import ObjectDoesNotExist

View File

@@ -1,7 +1,11 @@
"""
Tests for course dates fragment.
"""
from datetime import timedelta, datetime
from __future__ import absolute_import
from datetime import datetime, timedelta
import six
from django.urls import reverse
from student.tests.factories import UserFactory
@@ -9,7 +13,6 @@ from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
TEST_PASSWORD = 'test'
@@ -32,7 +35,7 @@ class TestCourseDatesFragmentView(ModuleStoreTestCase):
self.dates_fragment_url = reverse(
'openedx.course_experience.mobile_dates_fragment_view',
kwargs={
'course_id': unicode(self.course.id)
'course_id': six.text_type(self.course.id)
}
)

View File

@@ -2,40 +2,43 @@
"""
Tests for the course home page.
"""
from __future__ import absolute_import
from datetime import datetime, timedelta
import ddt
import mock
import six
from django.conf import settings
from django.urls import reverse
from django.http import QueryDict
from django.urls import reverse
from django.utils.http import urlquote_plus
from django.utils.timezone import now
from pytz import UTC
from waffle.models import Flag
from waffle.testutils import override_flag
from django_comment_common.models import (
FORUM_ROLE_ADMINISTRATOR,
FORUM_ROLE_MODERATOR,
FORUM_ROLE_GROUP_MODERATOR,
FORUM_ROLE_COMMUNITY_TA
)
from django_comment_client.tests.factories import RoleFactory
from course_modes.models import CourseMode
from course_modes.tests.factories import CourseModeFactory
from courseware.tests.helpers import get_expiration_banner_text
from django_comment_client.tests.factories import RoleFactory
from django_comment_common.models import (
FORUM_ROLE_ADMINISTRATOR,
FORUM_ROLE_COMMUNITY_TA,
FORUM_ROLE_GROUP_MODERATOR,
FORUM_ROLE_MODERATOR
)
from experiments.models import ExperimentData
from lms.djangoapps.commerce.models import CommerceConfiguration
from lms.djangoapps.commerce.utils import EcommerceService
from lms.djangoapps.course_goals.api import add_course_goal, remove_course_goal
from lms.djangoapps.courseware.tests.factories import (
InstructorFactory,
StaffFactory,
BetaTesterFactory,
OrgStaffFactory,
OrgInstructorFactory,
GlobalStaffFactory,
InstructorFactory,
OrgInstructorFactory,
OrgStaffFactory,
StaffFactory
)
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
@@ -44,15 +47,15 @@ from openedx.core.djangoapps.waffle_utils.testutils import WAFFLE_TABLES, overri
from openedx.features.course_duration_limits.config import EXPERIMENT_DATA_HOLDBACK_KEY, EXPERIMENT_ID
from openedx.features.course_duration_limits.models import CourseDurationLimitConfig
from openedx.features.course_experience import (
COURSE_ENABLE_UNENROLLED_ACCESS_FLAG,
SHOW_REVIEWS_TOOL_FLAG,
SHOW_UPGRADE_MSG_ON_COURSE_HOME,
UNIFIED_COURSE_TAB_FLAG,
COURSE_ENABLE_UNENROLLED_ACCESS_FLAG,
UNIFIED_COURSE_TAB_FLAG
)
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from util.date_utils import strftime_localized
from xmodule.course_module import COURSE_VISIBILITY_PRIVATE, COURSE_VISIBILITY_PUBLIC_OUTLINE, COURSE_VISIBILITY_PUBLIC
from xmodule.course_module import COURSE_VISIBILITY_PRIVATE, COURSE_VISIBILITY_PUBLIC, COURSE_VISIBILITY_PUBLIC_OUTLINE
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import CourseUserType, ModuleStoreTestCase, SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
@@ -89,7 +92,7 @@ def course_home_url(course):
Arguments:
course (CourseDescriptor): The course being tested.
"""
return course_home_url_from_string(unicode(course.id))
return course_home_url_from_string(six.text_type(course.id))
def course_home_url_from_string(course_key_string):

View File

@@ -1,17 +1,23 @@
"""
Tests for the Course Outline view and supporting views.
"""
from __future__ import absolute_import
import datetime
import json
import re
import six
from completion import waffle
from completion.models import BlockCompletion
from completion.test_utils import CompletionWaffleTestMixin
from django.contrib.sites.models import Site
from django.urls import reverse
from django.test import override_settings
from django.urls import reverse
from milestones.tests.utils import MilestonesTestCaseMixin
from mock import Mock, patch
from opaque_keys.edx.keys import CourseKey, UsageKey
from pyquery import PyQuery as pq
from six import text_type
from waffle.models import Switch
from waffle.testutils import override_switch
@@ -19,13 +25,11 @@ from waffle.testutils import override_switch
from courseware.tests.factories import StaffFactory
from gating import api as lms_gating_api
from lms.djangoapps.course_api.blocks.transformers.milestones import MilestonesAndSpecialExamsTransformer
from milestones.tests.utils import MilestonesTestCaseMixin
from opaque_keys.edx.keys import CourseKey, UsageKey
from openedx.core.lib.gating import api as gating_api
from openedx.features.course_experience.views.course_outline import (
CourseOutlineFragmentView, DEFAULT_COMPLETION_TRACKING_START
DEFAULT_COMPLETION_TRACKING_START,
CourseOutlineFragmentView
)
from pyquery import PyQuery as pq
from student.models import CourseEnrollment
from student.tests.factories import UserFactory
from xmodule.modulestore import ModuleStoreEnum
@@ -212,7 +216,7 @@ class TestCourseOutlinePageWithPrerequisites(SharedModuleStoreTestCase, Mileston
gating_block: (The prerequisite) The block that must be completed to get access to the gated block
"""
gating_api.add_prerequisite(self.course.id, unicode(gating_block.location))
gating_api.add_prerequisite(self.course.id, six.text_type(gating_block.location))
gating_api.set_required_content(self.course.id, gated_block.location, gating_block.location, 100)
def test_content_locked(self):
@@ -362,7 +366,7 @@ class TestCourseOutlineResumeCourse(SharedModuleStoreTestCase, CompletionWaffleT
"""
course_key = CourseKey.from_string(str(course.id))
# Fake a visit to sequence2/vertical2
block_key = UsageKey.from_string(unicode(sequential.location))
block_key = UsageKey.from_string(six.text_type(sequential.location))
completion = 1.0
BlockCompletion.objects.submit_completion(
user=self.user,
@@ -595,7 +599,7 @@ class TestCourseOutlinePreview(SharedModuleStoreTestCase):
masquerade_url = reverse(
'masquerade_update',
kwargs={
'course_key_string': unicode(course.id),
'course_key_string': six.text_type(course.id),
}
)
response = self.client.post(

View File

@@ -2,6 +2,8 @@
Tests for course verification sock
"""
from __future__ import absolute_import
import ddt
from course_modes.models import CourseMode

View File

@@ -1,10 +1,14 @@
"""
Tests for the course updates page.
"""
from __future__ import absolute_import
from datetime import datetime
from courseware.courses import get_course_info_usage_key
import six
from django.urls import reverse
from courseware.courses import get_course_info_usage_key
from openedx.core.djangoapps.waffle_utils.testutils import WAFFLE_TABLES
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
from openedx.features.course_experience.views.course_updates import STATUS_VISIBLE
@@ -28,7 +32,7 @@ def course_updates_url(course):
return reverse(
'openedx.course_experience.course_updates',
kwargs={
'course_id': unicode(course.id),
'course_id': six.text_type(course.id),
}
)

View File

@@ -1,7 +1,10 @@
"""
Tests for course welcome messages.
"""
from __future__ import absolute_import
import ddt
import six
from django.urls import reverse
from student.models import CourseEnrollment
@@ -23,7 +26,7 @@ def welcome_message_url(course):
return reverse(
'openedx.course_experience.welcome_message_fragment_view',
kwargs={
'course_id': unicode(course.id),
'course_id': six.text_type(course.id),
}
)
@@ -35,7 +38,7 @@ def latest_update_url(course):
return reverse(
'openedx.course_experience.latest_update_fragment_view',
kwargs={
'course_id': unicode(course.id),
'course_id': six.text_type(course.id),
}
)
@@ -47,7 +50,7 @@ def dismiss_message_url(course):
return reverse(
'openedx.course_experience.dismiss_welcome_message',
kwargs={
'course_id': unicode(course.id),
'course_id': six.text_type(course.id),
}
)