Skip to content
Snippets Groups Projects
Commit c621abe8 authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

test context processor

parent 6329eb3a
Branches main
No related tags found
No related merge requests found
Pipeline #150885 passed
[metadata] [metadata]
name = django-live-settings name = django-live-settings
version = 1.0 version = 1.0.1
description = A Django app to have some settings stored in db, and editable at runtime description = A Django app to have some settings stored in db, and editable at runtime
long_description = file: README.rst long_description = file: README.rst
author = Bryan Brancotte author = Bryan Brancotte
......
...@@ -47,9 +47,6 @@ TEMPLATES = [ ...@@ -47,9 +47,6 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'basetheme_bootstrap.context_processors.processors',
'strass_app.context_processors.enrich_with_status',
'strass_app.context_processors.add_google_analytics_tracker',
"live_settings.context_processors.processors", "live_settings.context_processors.processors",
], ],
}, },
......
{%if live_settings.blabla__int == 0 %}
IS_0
{%else%}
IS_NONE
{%endif%}
\ No newline at end of file
import logging
from django.test import TestCase as DjangoTestCase
from django.urls import reverse
from live_settings import live_settings
logger = logging.getLogger(__name__)
class LiveSettingsTestCase(DjangoTestCase):
def test_view_works(self):
url = reverse('foo')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn("IS_NONE", str(response.content))
self.assertNotIn("IS_0", str(response.content))
live_settings.blabla=0
response = self.client.get(url)
self.assertIn("IS_0", str(response.content))
self.assertNotIn("IS_NONE", str(response.content))
\ No newline at end of file
from django.urls import path, include from django.urls import path, include
from django.views.generic import TemplateView
urlpatterns = [ urlpatterns = [
path('live_settings/', include("live_settings.urls")), path('live_settings/', include("live_settings.urls")),
path('foo/', TemplateView.as_view(template_name='tests/foo.html'), name='foo'),
] ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment