fix: check enterprise_enabled in is_enterprise_learner

This commit is contained in:
Long Lin
2021-10-19 17:58:19 -04:00
committed by Longsheng Lin
parent d245c0d123
commit 34418a2667
5 changed files with 20 additions and 6 deletions

View File

@@ -481,6 +481,15 @@ class TestEnterpriseUtils(TestCase):
assert not mock_cache_set.called
@mock.patch('django.core.cache.cache.set')
@mock.patch('django.core.cache.cache.get')
@mock.patch('openedx.features.enterprise_support.api.enterprise_enabled', return_value=False)
def test_is_enterprise_learner_enterprise_disabled(self, _, mock_cache_get, mock_cache_set):
assert not is_enterprise_learner(self.user)
assert not is_enterprise_learner(self.user.id)
assert not mock_cache_get.called
assert not mock_cache_set.called
@mock.patch('openedx.features.enterprise_support.utils.reverse')
def test_get_enterprise_slug_login_url_no_reverse_match(self, mock_reverse):
mock_reverse.side_effect = NoReverseMatch