コード例 #1
0
    def test_set_read_only_env_var_on(self):
        """
        Check that if the environment variable is set to anything whilst the
        setting is undefined, AppConfig.ready() sets read only mode ON.
        """
        with set_env_vars(DJANGO_READ_ONLY="something"):
            django_read_only.set_read_only()

            assert django_read_only.read_only
コード例 #2
0
    def test_set_read_only_default_false(self):
        """
        Check that, in the absence of a value for the setting and environment
        variable, AppConfig.ready() defaults read only mode to OFF.
        """
        with set_env_vars(DJANGO_READ_ONLY=""):
            django_read_only.set_read_only()

            assert not django_read_only.read_only
コード例 #3
0
    def test_set_read_only_setting_precedence_to_env_var(self):
        """
        Check that if both the setting and environment variable are set,
        the setting takes precendence.
        """
        with set_env_vars(DJANGO_READ_ONLY="=something"), override_settings(
                DJANGO_READ_ONLY=False):
            django_read_only.set_read_only()

            assert not django_read_only.read_only
コード例 #4
0
    def test_set_read_only_setting_on(self):
        """
        Check that if the setting is True, AppConfig.ready() defaults read only
        mode to ON.
        """
        with set_env_vars(DJANGO_READ_ONLY=""), override_settings(
                DJANGO_READ_ONLY=True):
            django_read_only.set_read_only()

            assert django_read_only.read_only