diff --git a/lms/lib/courseware_search/test/test_lms_filter_generator.py b/lms/lib/courseware_search/test/test_lms_filter_generator.py index a57e9e195c..84fd7da6a6 100644 --- a/lms/lib/courseware_search/test/test_lms_filter_generator.py +++ b/lms/lib/courseware_search/test/test_lms_filter_generator.py @@ -105,7 +105,7 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase): self.assertEqual('LogistrationX', exclude_orgs[0]) self.assertEqual('TestSiteX', exclude_orgs[1]) - @patch('openedx.core.djangoapps.site_configuration.helpers.get_all_orgs', Mock(return_value=[])) + @patch('openedx.core.djangoapps.site_configuration.helpers.get_all_orgs', Mock(return_value=set())) def test_no_excludes_with_no_orgs(self): """ Test when no org is present - nothing to exclude """ _, _, exclude_dictionary = LmsSearchFilterGenerator.generate_field_filters(user=self.user) @@ -120,7 +120,7 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase): @patch( 'openedx.core.djangoapps.site_configuration.helpers.get_all_orgs', - Mock(return_value=["TestSite1", "TestSite2", "TestSite3", "TestSite4"]) + Mock(return_value={"TestSite1", "TestSite2", "TestSite3", "TestSite4"}) ) def test_excludes_multi_orgs(self): _, _, exclude_dictionary = LmsSearchFilterGenerator.generate_field_filters(user=self.user) @@ -134,7 +134,7 @@ class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase): @patch( 'openedx.core.djangoapps.site_configuration.helpers.get_all_orgs', - Mock(return_value=["TestSite1", "TestSite2", "TestSite3", "TestSite4"]) + Mock(return_value={"TestSite1", "TestSite2", "TestSite3", "TestSite4"}) ) @patch('openedx.core.djangoapps.site_configuration.helpers.get_value', Mock(return_value='TestSite3')) def test_excludes_multi_orgs_within(self): diff --git a/openedx/core/djangoapps/site_configuration/helpers.py b/openedx/core/djangoapps/site_configuration/helpers.py index eb4c0d737c..4af9bcd0f9 100644 --- a/openedx/core/djangoapps/site_configuration/helpers.py +++ b/openedx/core/djangoapps/site_configuration/helpers.py @@ -210,7 +210,7 @@ def get_all_orgs(): This can be used, for example, to do filtering. Returns: - A list of all organizations present in the site configuration. + A set of all organizations present in the site configuration. """ # Import is placed here to avoid model import at project startup. from openedx.core.djangoapps.site_configuration.models import SiteConfiguration diff --git a/openedx/core/djangoapps/site_configuration/models.py b/openedx/core/djangoapps/site_configuration/models.py index b20631fe93..6af78a171e 100644 --- a/openedx/core/djangoapps/site_configuration/models.py +++ b/openedx/core/djangoapps/site_configuration/models.py @@ -114,7 +114,7 @@ class SiteConfiguration(models.Model): for example, to do filtering. Returns: - A list of all organizations present in site configuration. + A set of all organizations present in site configuration. """ org_filter_set = set() diff --git a/openedx/core/djangoapps/site_configuration/tests/test_models.py b/openedx/core/djangoapps/site_configuration/tests/test_models.py index afd262d889..a753e6cbb7 100644 --- a/openedx/core/djangoapps/site_configuration/tests/test_models.py +++ b/openedx/core/djangoapps/site_configuration/tests/test_models.py @@ -4,6 +4,7 @@ Tests for site configuration's django models. from __future__ import absolute_import from mock import patch +import six from django.test import TestCase from django.db import IntegrityError, transaction @@ -321,10 +322,7 @@ class SiteConfigurationTests(TestCase): ) # Test that the default value is returned if the value for the given key is not found in the configuration - self.assertListEqual( - list(SiteConfiguration.get_all_orgs()), - expected_orgs, - ) + six.assertCountEqual(self, SiteConfiguration.get_all_orgs(), expected_orgs) def test_get_all_orgs_returns_only_enabled(self): """ @@ -343,7 +341,4 @@ class SiteConfigurationTests(TestCase): ) # Test that the default value is returned if the value for the given key is not found in the configuration - self.assertListEqual( - list(SiteConfiguration.get_all_orgs()), - expected_orgs, - ) + six.assertCountEqual(self, SiteConfiguration.get_all_orgs(), expected_orgs)