Code

*** empty log message ***
[roundup.git] / test / test_template_parser.py
1 # $Id: test_template_parser.py,v 1.1 2002-08-02 23:45:41 richard Exp $
3 import unittest
4 from roundup import template_parser
6 class TemplateParserTestCase(unittest.TestCase):
7    def testParser(self):
8         parser = template_parser.RoundupTemplate()
9         s = '''
10 <table border=0 cellspacing=5 cellpadding=0>
11  <tr>
12   <td bgcolor="ffffea">
13    <property name="prop1">
14     <require permission="perm1">
15      <display call="field('prop1')">
16     <else>
17      <display call="plain('prop1')">
18     </require>
19    </property>
20   </td>
21  </tr>
22 </table>
24 <table border=0 cellspacing=5 cellpadding=0>
25  <property name="prop2">
26   <tr>
27    <td class="form-label">Prop2:</td>
28    <td class="form-text">
29     <require permission="perm2">
30      <display call="field('prop2')">
31     <else>
32      <display call="plain('prop2')">
33     </require>
34    </td>
35   </tr>
36  </property>
37 </table>'''
38         parser.feed(s)
39         self.assertEqual(template_parser.display(parser.structure),
40 '\n<table border="0" cellspacing="5" cellpadding="0">\n <tr>\n  <td bgcolor="ffffea">\n   PROPERTY: [(\'name\', \'prop1\')] \n     TEST: [(\'permission\', \'perm1\')]\n OK...  \n       DISPLAY: [(\'call\', "field(\'prop1\')")]  \n     FAIL...  \n       DISPLAY: [(\'call\', "plain(\'prop1\')")]  \n     \n   \n  </td>\n </tr>\n</table>\n\n<table border="0" cellspacing="5" cellpadding="0">\n PROPERTY: [(\'name\', \'prop2\')] \n  <tr>\n   <td class="form-label">Prop2:</td>\n   <td class="form-text">\n     TEST: [(\'permission\', \'perm2\')]\n OK...  \n       DISPLAY: [(\'call\', "field(\'prop2\')")]  \n     FAIL...  \n       DISPLAY: [(\'call\', "plain(\'prop2\')")]  \n     \n   </td>\n  </tr>\n \n</table>')
42 def suite():
43    return unittest.makeSuite(TemplateParserTestCase, 'test')
46 #
47 # $Log: not supported by cvs2svn $
48 # Revision 1.12  2002/07/14 06:05:50  richard
49 #  . fixed the date module so that Date(". - 2d") works
50 #
51 # Revision 1.11  2002/02/21 23:34:52  richard
52 # Oops, there's 24 hours in a day, and subtraction of intervals now works
53 # properly.
54 #
55 # Revision 1.10  2002/02/21 23:11:45  richard
56 #  . fixed some problems in date calculations (calendar.py doesn't handle over-
57 #    and under-flow). Also, hour/minute/second intervals may now be more than
58 #    99 each.
59 #
60 # Revision 1.9  2002/02/21 06:57:39  richard
61 #  . Added popup help for classes using the classhelp html template function.
62 #    - add <display call="classhelp('priority', 'id,name,description')">
63 #      to an item page, and it generates a link to a popup window which displays
64 #      the id, name and description for the priority class. The description
65 #      field won't exist in most installations, but it will be added to the
66 #      default templates.
67 #
68 # Revision 1.8  2002/01/16 07:02:57  richard
69 #  . lots of date/interval related changes:
70 #    - more relaxed date format for input
71 #
72 # Revision 1.7  2001/08/13 23:01:53  richard
73 # fixed a 2.1-ism
74 #
75 # Revision 1.6  2001/08/07 00:24:43  richard
76 # stupid typo
77 #
78 # Revision 1.5  2001/08/07 00:15:51  richard
79 # Added the copyright/license notice to (nearly) all files at request of
80 # Bizar Software.
81 #
82 # Revision 1.4  2001/07/29 23:32:13  richard
83 # Fixed bug in unit test ;)
84 #
85 # Revision 1.3  2001/07/29 07:01:39  richard
86 # Added vim command to all source so that we don't get no steenkin' tabs :)
87 #
88 # Revision 1.2  2001/07/29 06:42:20  richard
89 # Added Interval tests.
90 #
91 # Revision 1.1  2001/07/27 06:55:07  richard
92 # moving tests -> test
93 #
94 # Revision 1.2  2001/07/25 04:34:31  richard
95 # Added id and log to tests files...
96 #
97 #
98 # vim: set filetype=python ts=4 sw=4 et si