| 1 |
from unittest import mock |
| 2 |
|
| 3 |
from django.core.exceptions import ImproperlyConfigured |
| 4 |
from django.test import TestCase |
| 5 |
|
| 6 |
from guardian.conf import settings as guardian_settings |
| 7 |
from guardian.ctypes import get_content_type |
| 8 |
|
| 9 |
|
| 10 |
class TestConfiguration(TestCase): |
| 11 |
def test_check_configuration(self): |
| 12 |
with mock.patch("guardian.conf.settings.RENDER_403", True): |
| 13 |
with mock.patch("guardian.conf.settings.RAISE_403", True): |
| 14 |
self.assertRaises(ImproperlyConfigured, guardian_settings.check_configuration) |
| 15 |
|
| 16 |
def test_get_content_type(self): |
| 17 |
with mock.patch( |
| 18 |
"guardian.conf.settings.GET_CONTENT_TYPE", "guardian.testapp.tests.test_conf.get_test_content_type" |
| 19 |
): |
| 20 |
self.assertEqual(get_content_type(None), "x") |
| 21 |
|
| 22 |
|
| 23 |
def get_test_content_type(obj): |
| 24 |
"""Used in TestConfiguration.test_get_content_type().""" |
| 25 |
return "x" |