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

Source Code for Module pytils.test.templatetags.test_numeral

 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' numeral templatetags for Django web framework 
18  """ 
19   
20  __id__ = __revision__ = "$Id: test_numeral.py 76 2007-02-27 15:38:53Z the.pythy $" 
21  __url__ = "$URL: https://pythy.googlecode.com/svn/trunk/pytils/pytils/test/templatetags/test_numeral.py $" 
22   
23  from pytils.test.templatetags import helpers 
24   
25 -class NumeralDefaultTestCase(helpers.TemplateTagTestCase):
26
27 - def test_load(self):
28 self.check_template_tag('load_tag', '{% load pytils_numeral %}', {}, '')
29
31 self.check_template_tag('choose_plural', 32 '{% load pytils_numeral %}{{ val|choose_plural:"гвоздь,гвоздя,гвоздей" }}', 33 {'val': 10}, 34 'гвоздей')
35
36 - def test_rubles_filter(self):
37 self.check_template_tag('rubles', 38 '{% load pytils_numeral %}{{ val|rubles }}', 39 {'val': 10.1}, 40 'десять рублей десять копеек')
41
42 - def test_in_words_filter(self):
43 self.check_template_tag('in_words', 44 '{% load pytils_numeral %}{{ val|in_words }}', 45 {'val': 21}, 46 'двадцать один') 47 48 self.check_template_tag('in_words', 49 '{% load pytils_numeral %}{{ val|in_words:"NEUTER" }}', 50 {'val': 21}, 51 'двадцать одно')
52
53 - def sum_string_tag(self):
54 self.check_template_tag('sum_string', 55 '{% load pytils_numeral %}{% sum_string val "MALE" "пример,пример,примеров" %}', 56 {'val': 21}, 57 'двадцать один пример')
58 59 # без отладки, если ошибка -- по умолчанию пустая строка
61 self.check_template_tag('choose_plural_error', 62 '{% load pytils_numeral %}{{ val|choose_plural:"вариант" }}', 63 {'val': 1}, 64 '')
65 66 67 if __name__ == '__main__': 68 import unittest 69 unittest.main() 70