Package pytils :: Package test :: Package templatetags :: Module test_translit
[hide private]

Source Code for Module pytils.test.templatetags.test_translit

 1  # -*- coding: utf-8 -*- 
 2  # PyTils - simple processing for russian strings 
 3  # Copyright (C) 2006-2007  Yury Yurevich 
 4  # 
 5  # http://gorod-omsk.ru/blog/pythy/projects/pytils/ 
 6  # 
 7  # This program is free software; you can redistribute it and/or 
 8  # modify it under the terms of the GNU General Public License 
 9  # as published by the Free Software Foundation, version 2 
10  # of the License. 
11  # 
12  # This program is distributed in the hope that it will be useful, 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  # GNU General Public License for more details. 
16  """ 
17  Unit tests for pytils' translit templatetags for Django web framework 
18  """ 
19   
20  __id__ = __revision__ = "$Id: test_translit.py 76 2007-02-27 15:38:53Z the.pythy $" 
21  __url__ = "$URL: https://pythy.googlecode.com/svn/trunk/pytils/pytils/test/templatetags/test_translit.py $" 
22   
23  from pytils.test.templatetags import helpers 
24   
25 -class TranslitDefaultTestCase(helpers.TemplateTagTestCase):
26
27 - def test_load(self):
28 self.check_template_tag('load_tag', '{% load pytils_translit %}', {}, '')
29
30 - def test_translify_filter(self):
31 self.check_template_tag('translify_filter', 32 '{% load pytils_translit %}{{ val|translify }}', 33 {'val': 'проверка'}, 34 'proverka')
35
36 - def test_detranslify_filter(self):
37 self.check_template_tag('detranslify_filter', 38 '{% load pytils_translit %}{{ val|detranslify }}', 39 {'val': 'proverka'}, 40 'проверка')
41
42 - def test_slugify_filter(self):
43 self.check_template_tag('slugify_filter', 44 '{% load pytils_translit %}{{ val|slugify }}', 45 {'val': 'Проверка связи'}, 46 'proverka-svyazi')
47 48 # без отладки, если ошибка -- по умолчанию пустая строка
49 - def test_detranslify_error(self):
50 self.check_template_tag('detranslify_error', 51 '{% load pytils_translit %}{{ val|detranslify }}', 52 {'val': 'Проверка связи'}, 53 '')
54 55 56 if __name__ == '__main__': 57 import unittest 58 unittest.main() 59