Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/template_tests/filter_tests/test_yesno.py
blob: 43ea447caa42d5c1ea70d04ff6945044fc6044b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from django.template.defaultfilters import yesno
from django.test import SimpleTestCase


class FunctionTests(SimpleTestCase):

    def test_true(self):
        self.assertEqual(yesno(True), 'yes')

    def test_false(self):
        self.assertEqual(yesno(False), 'no')

    def test_none(self):
        self.assertEqual(yesno(None), 'maybe')

    def test_true_arguments(self):
        self.assertEqual(yesno(True, 'certainly,get out of town,perhaps'), 'certainly')

    def test_false_arguments(self):
        self.assertEqual(yesno(False, 'certainly,get out of town,perhaps'), 'get out of town')

    def test_none_two_arguments(self):
        self.assertEqual(yesno(None, 'certainly,get out of town'), 'get out of town')

    def test_none_three_arguments(self):
        self.assertEqual(yesno(None, 'certainly,get out of town,perhaps'), 'perhaps')