~justizin/zope.documenttemplate/id_marker_lp_569541

« back to all changes in this revision

Viewing changes to src/zope/documenttemplate/tests/testdt_if.py

  • Committer: ctheune
  • Date: 2007-05-03 20:50:46 UTC
  • Revision ID: svn-v4:62d5b8a3-27da-0310-9561-8e5933582275:zope.documenttemplate/trunk:75113
Moving code to satellite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
 
4
#
 
5
# This software is subject to the provisions of the Zope Public License,
 
6
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
 
7
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 
8
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
9
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 
10
# FOR A PARTICULAR PURPOSE
 
11
#
 
12
##############################################################################
 
13
"""Document Template Tests
 
14
 
 
15
$Id$
 
16
"""
 
17
import unittest
 
18
from zope.documenttemplate.tests.dtmltestbase import DTMLTestBase
 
19
 
 
20
class TestDT_If(DTMLTestBase):
 
21
 
 
22
 
 
23
    def testBasic(self):
 
24
 
 
25
        html = self.doc_class(
 
26
            u"""\
 
27
             <dtml-if value>
 
28
               The arguments were: <dtml-var value>
 
29
             </dtml-if>
 
30
            """)
 
31
 
 
32
        result1 = u"The arguments were: foo"
 
33
        result2 = u""
 
34
 
 
35
        self.assertEqual(html(value='foo').strip(), result1.strip())
 
36
        self.assertEqual(html().strip(), result2.strip())
 
37
 
 
38
 
 
39
    def testElse(self):
 
40
 
 
41
        html = self.doc_class(
 
42
            u"""\
 
43
             <dtml-if value>
 
44
               The arguments were: <dtml-var value>
 
45
             <dtml-else>
 
46
               No arguments were given.
 
47
             </dtml-if>
 
48
            """)
 
49
 
 
50
        result1 = u"The arguments were: foo"
 
51
        result2 = u"No arguments were given."
 
52
 
 
53
        self.assertEqual(html(value='foo').strip(), result1.strip())
 
54
        self.assertEqual(html().strip(), result2.strip())
 
55
 
 
56
    def testElIf(self):
 
57
 
 
58
        html = self.doc_class(
 
59
            u"""\
 
60
             <dtml-if value>
 
61
               The arguments were: <dtml-var value>
 
62
             <dtml-elif attribute>
 
63
               The attributes were: <dtml-var attribute>
 
64
             </dtml-if>
 
65
            """)
 
66
 
 
67
        result1 = u"The arguments were: foo"
 
68
        result2 = u"The attributes were: bar"
 
69
 
 
70
        self.assertEqual(html(value='foo', attribute='').strip(),
 
71
                         result1.strip())
 
72
        self.assertEqual(html(value='', attribute='bar').strip(),
 
73
                         result2.strip())
 
74
 
 
75
 
 
76
def test_suite():
 
77
    suite = unittest.TestSuite()
 
78
    suite.addTest(unittest.makeSuite(TestDT_If))
 
79
    return suite
 
80
 
 
81
 
 
82
 
 
83
if __name__ == '__main__':
 
84
    unittest.TextTestRunner().run(test_suite())