get_all_orgs returns a set, not a list. BOM-731
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user