Skip to content

Commit

Permalink
Add test checking override_settings compat
Browse files Browse the repository at this point in the history
  • Loading branch information
carltongibson committed Dec 14, 2017
1 parent 1692feb commit 3f9a54f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import unicode_literals

from django.test import TestCase
from django.test import TestCase, override_settings

from rest_framework.settings import APISettings
from rest_framework.settings import APISettings, api_settings


class TestSettings(TestCase):
Expand All @@ -28,6 +28,23 @@ def test_warning_raised_on_removed_setting(self):
'MAX_PAGINATE_BY': 100
})

def test_compatibility_with_override_settings(self):
"""
Ref #5658 & #2466: Documented usage of api_settings
is bound at import time:
from rest_framework.settings import api_settings
setting_changed signal hook must ensure bound instance
is refreshed.
"""
assert api_settings.PAGE_SIZE is None, "Checking a known default should be None"

with override_settings(REST_FRAMEWORK={'PAGE_SIZE': 10}):
assert api_settings.PAGE_SIZE == 10, "Setting should have been updated"

assert api_settings.PAGE_SIZE is None, "Setting should have been restored"


class TestSettingTypes(TestCase):
def test_settings_consistently_coerced_to_list(self):
Expand Down

0 comments on commit 3f9a54f

Please sign in to comment.