OpenSlides/tests/utils/test_template_tags_filters.py
Norman Jäckel 82c804e2d6 Inserted a new config variable 'Stop submitting of new motions'
Normal delegates can not submit a new motion when this is set to true. Inserted also a new template filter to relate to config variables in if-clauses.
2013-04-05 11:49:57 +02:00

40 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tests for openslides.utils.templatetags.tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:copyright: 20112013 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
from django.template import Template, Context
from openslides.utils.test import TestCase
from openslides.config.api import config
class ConfigTagAndFilter(TestCase):
def test_config_tag(self):
config['taiNg3reQuooGha4'] = 'iWoor0caThieK7yi'
template = Template("{% load tags %} The config var is {% get_config 'taiNg3reQuooGha4' %}.")
self.assertTrue('The config var is iWoor0caThieK7yi.' in template.render(Context({})))
def test_config_filter(self):
config['fkjTze56ncuejWqs'] = 'REG56Hnmfk9TdfsD'
template = Template("{% load tags %} The config var is {{ 'fkjTze56ncuejWqs'|get_config }}.")
self.assertTrue('The config var is REG56Hnmfk9TdfsD.' in template.render(Context({})))
def test_both_in_one(self):
config['jfhsnezfh452w6Fg'] = True
config['sdmvldkfgj4534gk'] = 'FdgfkR04jtg9f8bq'
template_code = """{% load tags %}
{% if 'jfhsnezfh452w6Fg'|get_config %}
{% get_config 'sdmvldkfgj4534gk' %}
{% else %}
bad_e0fvkfHFD
{% endif %}"""
template = Template(template_code)
self.assertTrue('FdgfkR04jtg9f8bq' in template.render(Context({})))
self.assertFalse('bad_e0fvkfHFD' in template.render(Context({})))