The service is specific to 2U and should not be installed by default. When we try to patch objects from that library, that can only be done if the original object is importable. So those tests don't make sense to have in the base system which you should be able to run without the edx-name-affirmation library.
26 lines
923 B
Python
26 lines
923 B
Python
""" Tests for Name Affirmation API utils """
|
|
|
|
from unittest import TestCase
|
|
from unittest.mock import patch
|
|
|
|
import ddt
|
|
from edx_django_utils.plugins import PluginError
|
|
|
|
from openedx.features.name_affirmation_api.utils import is_name_affirmation_installed
|
|
|
|
|
|
@ddt.ddt
|
|
class TestNameAffirmationAPIUtils(TestCase):
|
|
""" Tests for Name Affirmation API utils """
|
|
|
|
@patch('openedx.features.name_affirmation_api.utils.PluginManager')
|
|
def test_name_affirmation_installed(self, mock_manager):
|
|
mock_manager.get_plugin.return_value = 'mock plugin'
|
|
self.assertTrue(is_name_affirmation_installed())
|
|
|
|
@patch('openedx.features.name_affirmation_api.utils.PluginManager')
|
|
def test_name_affirmation_not_installed(self, mock_manager):
|
|
mock_manager.side_effect = PluginError('No such plugin')
|
|
with self.assertRaises(PluginError):
|
|
self.assertFalse(is_name_affirmation_installed())
|