@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Helper Methods
|
||||
"""
|
||||
import six
|
||||
|
||||
|
||||
def _get_key(key_or_id, key_cls):
|
||||
@@ -10,6 +11,6 @@ def _get_key(key_or_id, key_cls):
|
||||
"""
|
||||
return (
|
||||
key_cls.from_string(key_or_id)
|
||||
if isinstance(key_or_id, basestring)
|
||||
if isinstance(key_or_id, six.string_types)
|
||||
else key_or_id
|
||||
)
|
||||
|
||||
@@ -3,6 +3,9 @@ This file contains implementation override of SearchFilterGenerator which will a
|
||||
* Filter by all courses in which the user is enrolled in
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
from search.filter_generator import SearchFilterGenerator
|
||||
|
||||
from openedx.core.djangoapps.course_groups.partition_scheme import CohortPartitionScheme
|
||||
@@ -32,7 +35,7 @@ class LmsSearchFilterGenerator(SearchFilterGenerator):
|
||||
field_dictionary['course'] = []
|
||||
elif not kwargs.get('course_id'):
|
||||
user_enrollments = self._enrollments_for_user(kwargs['user'])
|
||||
field_dictionary['course'] = [unicode(enrollment.course_id) for enrollment in user_enrollments]
|
||||
field_dictionary['course'] = [six.text_type(enrollment.course_id) for enrollment in user_enrollments]
|
||||
|
||||
# if we have an org filter, only include results for this org filter
|
||||
course_org_filter = configuration_helpers.get_current_site_orgs()
|
||||
|
||||
@@ -3,6 +3,8 @@ This file contains implementation override of SearchResultProcessor which will a
|
||||
* Blends in "location" property
|
||||
* Confirms user access to object
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.urls import reverse
|
||||
from opaque_keys.edx.keys import CourseKey, UsageKey
|
||||
from search.result_processor import SearchResultProcessor
|
||||
|
||||
@@ -3,6 +3,8 @@ This file contains implementation override of SearchInitializer which will allow
|
||||
* To set initial set of masquerades and other parameters
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from search.initializer import SearchInitializer
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
"""
|
||||
Tests for the lms_filter_generator
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
from mock import Mock, patch
|
||||
|
||||
from lms.lib.courseware_search.lms_filter_generator import LmsSearchFilterGenerator
|
||||
@@ -63,8 +66,8 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
|
||||
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
|
||||
|
||||
self.assertIn('start_date', filter_dictionary)
|
||||
self.assertIn(unicode(self.courses[0].id), field_dictionary['course'])
|
||||
self.assertIn(unicode(self.courses[1].id), field_dictionary['course'])
|
||||
self.assertIn(six.text_type(self.courses[0].id), field_dictionary['course'])
|
||||
self.assertIn(six.text_type(self.courses[1].id), field_dictionary['course'])
|
||||
|
||||
def test_course_id_provided(self):
|
||||
"""
|
||||
@@ -72,11 +75,11 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
|
||||
user=self.user,
|
||||
course_id=unicode(self.courses[0].id)
|
||||
course_id=six.text_type(self.courses[0].id)
|
||||
)
|
||||
|
||||
self.assertIn('start_date', filter_dictionary)
|
||||
self.assertEqual(unicode(self.courses[0].id), field_dictionary['course'])
|
||||
self.assertEqual(six.text_type(self.courses[0].id), field_dictionary['course'])
|
||||
|
||||
def test_user_not_provided(self):
|
||||
"""
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
"""
|
||||
Tests for the lms_result_processor
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
|
||||
from courseware.tests.factories import UserFactory
|
||||
from lms.lib.courseware_search.lms_result_processor import LmsSearchResultProcessor
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
@@ -71,15 +75,18 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
|
||||
|
||||
srp = LmsSearchResultProcessor(
|
||||
{
|
||||
"course": unicode(self.course.id),
|
||||
"id": unicode(self.html.scope_ids.usage_id),
|
||||
"course": six.text_type(self.course.id),
|
||||
"id": six.text_type(self.html.scope_ids.usage_id),
|
||||
"content": {"text": "This is the html text"}
|
||||
},
|
||||
"test"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
srp.url, "/courses/{}/jump_to/{}".format(unicode(self.course.id), unicode(self.html.scope_ids.usage_id)))
|
||||
srp.url, "/courses/{}/jump_to/{}".format(
|
||||
six.text_type(self.course.id),
|
||||
six.text_type(self.html.scope_ids.usage_id))
|
||||
)
|
||||
|
||||
def test_should_remove(self):
|
||||
"""
|
||||
@@ -87,8 +94,8 @@ class LmsSearchResultProcessorTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
srp = LmsSearchResultProcessor(
|
||||
{
|
||||
"course": unicode(self.course.id),
|
||||
"id": unicode(self.html.scope_ids.usage_id),
|
||||
"course": six.text_type(self.course.id),
|
||||
"id": six.text_type(self.html.scope_ids.usage_id),
|
||||
"content": {"text": "This is html test text"}
|
||||
},
|
||||
"test"
|
||||
|
||||
Reference in New Issue
Block a user