本文整理汇总了Python中lms.lib.courseware_search.lms_filter_generator.LmsSearchFilterGenerator类的典型用法代码示例。如果您正苦于以下问题:Python LmsSearchFilterGenerator类的具体用法?Python LmsSearchFilterGenerator怎么用?Python LmsSearchFilterGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LmsSearchFilterGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_staff_masquerading_added_to_group
def test_staff_masquerading_added_to_group(self):
"""
Tests that initializer sets masquerading for a staff user in a group.
"""
# Verify that there is no masquerading group initially
_, filter_directory, _ = LmsSearchFilterGenerator.generate_field_filters( # pylint: disable=unused-variable
user=self.global_staff,
course_id=unicode(self.course.id)
)
# User is staff by default, no content groups filter is set - see all
self.assertNotIn('content_groups', filter_directory)
# Install a masquerading group
request = self._create_mock_json_request(
self.global_staff,
body='{"role": "student", "user_partition_id": 0, "group_id": 1}'
)
handle_ajax(request, unicode(self.course.id))
# Call initializer
LmsSearchInitializer.set_search_enviroment(
request=request,
course_id=unicode(self.course.id)
)
# Verify that there is masquerading group after masquerade
_, filter_directory, _ = LmsSearchFilterGenerator.generate_field_filters( # pylint: disable=unused-variable
user=self.global_staff,
course_id=unicode(self.course.id)
)
self.assertEqual(filter_directory['content_groups'], [unicode(1)])
示例2: test_invalid_course_key
def test_invalid_course_key(self):
"""
Test system raises an error if no course found.
"""
self.add_seq_with_content_groups()
with self.assertRaises(InvalidKeyError):
LmsSearchFilterGenerator.generate_field_filters(user=self.user, course_id="this_is_false_course_id")
示例3: test_content_multiple_groups_id_provided
def test_content_multiple_groups_id_provided(self):
"""
Tests that we get content groups IDs when course is assigned to cohort
which is assigned to multiple content groups.
"""
self.add_seq_with_content_groups()
self.add_user_to_cohort_group()
# Second cohort link
link_cohort_to_partition_group(
self.second_cohort,
self.user_partition.id,
self.groups[0].id,
)
self.courses[0].save()
modulestore().update_item(self.courses[0], self.user.id)
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user,
course_id=unicode(self.courses[0].id)
)
self.assertTrue('start_date' in filter_dictionary)
self.assertEqual(unicode(self.courses[0].id), field_dictionary['course'])
# returns only first group, relevant to current user
self.assertEqual([unicode(self.content_groups[0])], filter_dictionary['content_groups'])
示例4: test_excludes_microsite
def test_excludes_microsite(self):
""" By default there is the test microsite to exclude """
_, _, exclude_dictionary = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
self.assertIn('org', exclude_dictionary)
exclude_orgs = exclude_dictionary['org']
self.assertEqual(1, len(exclude_orgs))
self.assertEqual('TestMicrositeX', exclude_orgs[0])
示例5: test_user_not_provided
def test_user_not_provided(self):
"""
Tests that we get empty list of courses in case the user is not provided
"""
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters()
self.assertTrue('start_date' in filter_dictionary)
self.assertEqual(0, len(field_dictionary['course']))
示例6: test_excludes_multi_microsites
def test_excludes_multi_microsites(self):
_, _, exclude_dictionary = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
self.assertIn('org', exclude_dictionary)
exclude_orgs = exclude_dictionary['org']
self.assertEqual(4, len(exclude_orgs))
self.assertIn('TestMicrosite1', exclude_orgs)
self.assertIn('TestMicrosite2', exclude_orgs)
self.assertIn('TestMicrosite3', exclude_orgs)
self.assertIn('TestMicrosite4', exclude_orgs)
示例7: test_course_id_not_provided
def test_course_id_not_provided(self):
"""
Tests that we get the list of IDs of courses the user is enrolled in when the course ID is null or not provided
"""
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
self.assertTrue('start_date' in filter_dictionary)
self.assertIn(unicode(self.courses[0].id), field_dictionary['course'])
self.assertIn(unicode(self.courses[1].id), field_dictionary['course'])
示例8: test_excludes_site_org
def test_excludes_site_org(self):
"""
By default site orgs not belonging to current site org should be excluded.
"""
_, _, exclude_dictionary = LmsSearchFilterGenerator.generate_field_filters(user=self.user)
self.assertIn('org', exclude_dictionary)
exclude_orgs = exclude_dictionary['org']
self.assertEqual(2, len(exclude_orgs))
self.assertEqual('LogistrationX', exclude_orgs[0])
self.assertEqual('TestSiteX', exclude_orgs[1])
示例9: test_course_id_provided
def test_course_id_provided(self):
"""
Tests that we get the course ID when the course ID is provided
"""
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user, course_id=unicode(self.courses[0].id)
)
self.assertTrue("start_date" in filter_dictionary)
self.assertEqual(unicode(self.courses[0].id), field_dictionary["course"])
示例10: test_content_group_with_cohort_not_provided
def test_content_group_with_cohort_not_provided(self):
"""
Tests that we don't get content group ID when course has no cohorts
"""
self.add_seq_with_content_groups()
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user, course_id=unicode(self.courses[0].id)
)
self.assertTrue("start_date" in filter_dictionary)
self.assertEqual(unicode(self.courses[0].id), field_dictionary["course"])
self.assertEqual(None, filter_dictionary["content_groups"])
示例11: test_content_group_id_provided
def test_content_group_id_provided(self):
"""
Tests that we get the content group ID when course is assigned to cohort
which is assigned content group.
"""
self.add_seq_with_content_groups()
self.add_user_to_cohort_group()
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user, course_id=unicode(self.courses[0].id)
)
self.assertTrue("start_date" in filter_dictionary)
self.assertEqual(unicode(self.courses[0].id), field_dictionary["course"])
self.assertEqual(unicode(self.content_groups[0]), filter_dictionary["content_groups"])
示例12: test_split_test_with_user_groups_user_not_assigned
def test_split_test_with_user_groups_user_not_assigned(self):
"""
Tests that we don't get user group ID when user is not assigned to a split test group
"""
self.add_split_test()
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user,
course_id=unicode(self.courses[1].id)
)
self.assertTrue('start_date' in filter_dictionary)
self.assertEqual(unicode(self.courses[1].id), field_dictionary['course'])
self.assertEqual(None, filter_dictionary['content_groups'])
示例13: test_content_group_id_not_provided
def test_content_group_id_not_provided(self):
"""
Tests that we don't get content group ID when course is assigned a cohort
but cohort is not assigned to content group.
"""
self.add_seq_with_content_groups(groups=[])
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user,
course_id=unicode(self.courses[0].id)
)
self.assertTrue('start_date' in filter_dictionary)
self.assertEqual(unicode(self.courses[0].id), field_dictionary['course'])
self.assertEqual(None, filter_dictionary['content_groups'])
示例14: test_split_test_with_user_groups_user_assigned
def test_split_test_with_user_groups_user_assigned(self):
"""
Tests that we get user group ID when user is assigned to a split test group
"""
self.add_split_test()
self.add_user_to_splittest_group()
field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters(
user=self.user,
course_id=unicode(self.courses[1].id)
)
partition_group = self.split_test_user_partition.scheme.get_group_for_user(
CourseKey.from_string(unicode(self.courses[1].id)),
self.user,
self.split_test_user_partition,
assign=False,
)
self.assertTrue('start_date' in filter_dictionary)
self.assertEqual(unicode(self.courses[1].id), field_dictionary['course'])
self.assertEqual([unicode(partition_group.id)], filter_dictionary['content_groups'])
示例15: test_staff_masquerading_as_a_student_user
def test_staff_masquerading_as_a_student_user(self):
"""
Tests that initializer sets masquerading for a staff user as student.
"""
# Install a masquerading group
request = self._create_mock_json_request(
self.global_staff,
body='{"role": "student"}'
)
handle_ajax(request, unicode(self.course.id))
# Call initializer
LmsSearchInitializer.set_search_enviroment(
request=request,
course_id=unicode(self.course.id)
)
# Verify that there is masquerading group after masquerade
_, filter_directory, _ = LmsSearchFilterGenerator.generate_field_filters( # pylint: disable=unused-variable
user=self.global_staff,
course_id=unicode(self.course.id)
)
self.assertEqual(filter_directory['content_groups'], None)