Add test checking override_settings compat · encode/django-rest-framework@3f9a54f (original) (raw)
1
1
`from future import unicode_literals
`
2
2
``
3
``
`-
from django.test import TestCase
`
``
3
`+
from django.test import TestCase, override_settings
`
4
4
``
5
``
`-
from rest_framework.settings import APISettings
`
``
5
`+
from rest_framework.settings import APISettings, api_settings
`
6
6
``
7
7
``
8
8
`class TestSettings(TestCase):
`
`@@ -28,6 +28,23 @@ def test_warning_raised_on_removed_setting(self):
`
28
28
`'MAX_PAGINATE_BY': 100
`
29
29
` })
`
30
30
``
``
31
`+
def test_compatibility_with_override_settings(self):
`
``
32
`+
"""
`
``
33
`+
Ref #5658 & #2466: Documented usage of api_settings
`
``
34
`+
is bound at import time:
`
``
35
+
``
36
`+
from rest_framework.settings import api_settings
`
``
37
+
``
38
`+
setting_changed signal hook must ensure bound instance
`
``
39
`+
is refreshed.
`
``
40
`+
"""
`
``
41
`+
assert api_settings.PAGE_SIZE is None, "Checking a known default should be None"
`
``
42
+
``
43
`+
with override_settings(REST_FRAMEWORK={'PAGE_SIZE': 10}):
`
``
44
`+
assert api_settings.PAGE_SIZE == 10, "Setting should have been updated"
`
``
45
+
``
46
`+
assert api_settings.PAGE_SIZE is None, "Setting should have been restored"
`
``
47
+
31
48
``
32
49
`class TestSettingTypes(TestCase):
`
33
50
`def test_settings_consistently_coerced_to_list(self):
`