Exemplo n.º 1
0
    def test_preferences_cp(self):
        request = RequestFactory().get('/')
        context = context_processors.preferences_cp(request)

        # context should have preferences.
        preferences = context['preferences']

        # preferences should have test MyPreferences object member.
        my_preferences = preferences.MyPreferences
        self.failUnless(isinstance(my_preferences, MyPreferences), \
                "%s should be instance of MyPreferences." % my_preferences)

        # With preferences_cp is loaded as a TEMPLATE_CONTEXT_PROCESSORS
        # templates should have access to preferences object.
        context_instance = RequestContext(request)
        context = template.Context({
            'request': RequestFactory,
        })
        t = Template("{% if preferences %}{{ preferences }}{% endif %}")
        self.failUnless(t.render(context_instance), "preferences should be \
available in template context.")

        t = Template("{% if preferences.MyPreferences %}{{ \
preferences.MyPreferences }}{% endif %}")
        self.failUnless(t.render(context_instance), "MyPreferences should be \
available as part of preferences var in template context.")
Exemplo n.º 2
0
    def test_preferences_cp(self):
        request = RequestFactory().get('/')
        context = context_processors.preferences_cp(request)

        # context should have preferences.
        preferences = context['preferences']

        # preferences should have test MyPreferences object member.
        my_preferences = preferences.MyPreferences
        self.failUnless(isinstance(my_preferences, MyPreferences), \
                "%s should be instance of MyPreferences." % my_preferences)

        # With preferences_cp is loaded as a TEMPLATE_CONTEXT_PROCESSORS
        # templates should have access to preferences object.
        context_instance = RequestContext(request)
        context = template.Context({
            'request': RequestFactory,
        })
        t = Template("{% if preferences %}{{ preferences }}{% endif %}")
        self.failUnless(
            t.render(context_instance), "preferences should be \
available in template context.")

        t = Template("{% if preferences.MyPreferences %}{{ \
preferences.MyPreferences }}{% endif %}")
        self.failUnless(
            t.render(context_instance), "MyPreferences should be \
available as part of preferences var in template context.")