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://www.pyobject.ru/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 102 2007-07-12 12:33:36Z the.pythy $" 
21  __url__ = "$URL: https://pythy.googlecode.com/svn/tags/pytils/0_2_2/pytils/test/templatetags/test_translit.py $" 
22   
23  from pytils.test.templatetags import helpers 
24   
25 -class TranslitDefaultTestCase(helpers.TemplateTagTestCase):
26
27 - def testLoad(self):
28 self.check_template_tag('load_tag', '{% load pytils_translit %}', {}, '')
29
30 - def testTranslifyFilter(self):
31 self.check_template_tag('translify_filter', 32 '{% load pytils_translit %}{{ val|translify }}', 33 {'val': 'проверка'}, 34 'proverka')
35
36 - def testDetranslifyFilter(self):
37 self.check_template_tag('detranslify_filter', 38 '{% load pytils_translit %}{{ val|detranslify }}', 39 {'val': 'proverka'}, 40 'проверка')
41
42 - def testSlugifyFilter(self):
43 self.check_template_tag('slugify_filter', 44 '{% load pytils_translit %}{{ val|slugify }}', 45 {'val': 'Проверка связи'}, 46 'proverka-svyazi')
47 48 # без отладки, если ошибка -- по умолчанию пустая строка
49 - def testDetranslifyError(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