Mercurial > p > roundup > code
annotate test/test_htmltemplate.py @ 563:0f58d6a35a8b
Wrote more unit tests for htmltemplate...
...and while I was at it, I polished off the implementation of some of
the functions so they behave sanely.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 22 Jan 2002 00:12:07 +0000 |
| parents | 13df980755fa |
| children | c7ead967db85 |
| rev | line source |
|---|---|
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 # |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 # Copyright (c) 2001 Richard Jones |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 # This module is free software, and you may redistribute it and/or modify |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 # under the same terms as Python, so long as this copyright message and |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 # disclaimer are retained in their original form. |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 # |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 # This module is distributed in the hope that it will be useful, |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 # |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
11 # $Id: test_htmltemplate.py,v 1.2 2002-01-22 00:12:07 richard Exp $ |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 import unittest, cgi |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 from roundup.htmltemplate import TemplateFunctions |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 from roundup import date |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
17 from roundup import password |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
18 from roundup.hyperdb import String, Password, Date, Interval, Link, Multilink |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 class Class: |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 def get(self, nodeid, attribute, default=None): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 if attribute == 'string': |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 return 'Node %s: I am a string'%nodeid |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 elif attribute == 'date': |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 return date.Date('2000-01-01') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 elif attribute == 'interval': |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 return date.Interval('-3d') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 elif attribute == 'link': |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 return '1' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 elif attribute == 'multilink': |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 return ['1', '2'] |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
32 elif attribute == 'password': |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
33 return password.Password('sekrit') |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 elif attribute == 'key': |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 return 'the key' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 elif attribute == 'html': |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 return '<html>hello, I am HTML</html>' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 def list(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 return ['1', '2'] |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 def getprops(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 return {'string': String(), 'date': Date(), 'interval': Interval(), |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 'link': Link('other'), 'multilink': Multilink('other'), |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
43 'password': Password(), 'html': String(), 'key': String()} |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 def labelprop(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 return 'key' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 class Database: |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 classes = {'other': Class()} |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 def getclass(self, name): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 return Class() |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 def __getattr(self, name): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 return Class() |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 class NodeCase(unittest.TestCase): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 def setUp(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 ''' Set up the harness for calling the individual tests |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 ''' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 self.tf = tf = TemplateFunctions() |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
59 tf.nodeid = '1' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 tf.cl = Class() |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 tf.properties = tf.cl.getprops() |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 tf.db = Database() |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 # def do_plain(self, property, escape=0): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 def testPlain_string(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 s = 'Node 1: I am a string' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 self.assertEqual(self.tf.do_plain('string'), s) |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
68 |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
69 def testPlain_password(self): |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
70 self.assertEqual(self.tf.do_plain('password'), '*encrypted*') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
71 |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 def testPlain_html(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 s = '<html>hello, I am HTML</html>' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 self.assertEqual(self.tf.do_plain('html', escape=0), s) |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 s = cgi.escape(s) |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
76 self.assertEqual(self.tf.do_plain('html', escape=1), s) |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
77 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 def testPlain_date(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 self.assertEqual(self.tf.do_plain('date'), '2000-01-01.00:00:00') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 def testPlain_interval(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 self.assertEqual(self.tf.do_plain('interval'), '- 3d') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 def testPlain_link(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
85 self.assertEqual(self.tf.do_plain('link'), 'the key') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
86 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
87 def testPlain_multilink(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
88 self.assertEqual(self.tf.do_plain('multilink'), '1, 2') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
89 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
91 # def do_field(self, property, size=None, showid=0): |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
92 def testField_string(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
93 self.assertEqual(self.tf.do_field('string'), |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
94 '<input name="string" value="Node 1: I am a string" size="30">') |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
95 self.assertEqual(self.tf.do_field('string', size=10), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
96 '<input name="string" value="Node 1: I am a string" size="10">') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
97 |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
98 def testField_password(self): |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
99 self.assertEqual(self.tf.do_field('password'), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
100 '<input type="password" name="password" size="30">') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
101 self.assertEqual(self.tf.do_field('password', size=10), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
102 '<input type="password" name="password" size="10">') |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
103 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
104 def testField_html(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
105 self.assertEqual(self.tf.do_field('html'), '<input name="html" ' |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
106 'value="<html>hello, I am HTML</html>" size="30">') |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
107 self.assertEqual(self.tf.do_field('html', size=10), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
108 '<input name="html" value="<html>hello, I am ' |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
109 'HTML</html>" size="10">') |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
110 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
111 def testField_date(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
112 self.assertEqual(self.tf.do_field('date'), |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
113 '<input name="date" value="2000-01-01.00:00:00" size="30">') |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
114 self.assertEqual(self.tf.do_field('date', size=10), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
115 '<input name="date" value="2000-01-01.00:00:00" size="10">') |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
116 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
117 def testField_interval(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
118 self.assertEqual(self.tf.do_field('interval'), |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
119 '<input name="interval" value="- 3d" size="30">') |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
120 self.assertEqual(self.tf.do_field('interval', size=10), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
121 '<input name="interval" value="- 3d" size="10">') |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
122 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
123 def testField_link(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
124 self.assertEqual(self.tf.do_field('link'), '''<select name="link"> |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
125 <option value="-1">- no selection -</option> |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
126 <option selected value="1">the key</option> |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
127 <option value="2">the key</option> |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
128 </select>''') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
129 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
130 def testField_multilink(self): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
131 self.assertEqual(self.tf.do_field('multilink'), |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
132 '<input name="multilink" size="30" value="the key,the key">') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
133 self.assertEqual(self.tf.do_field('multilink', size=10), |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
134 '<input name="multilink" size="10" value="the key,the key">') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
135 |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
136 # def do_menu(self, property, size=None, height=None, showid=0): |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
137 def testMenu_link(self): |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
138 self.assertEqual(self.tf.do_menu('link'), '''<select name="link"> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
139 <option value="-1">- no selection -</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
140 <option selected value="1">the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
141 <option value="2">the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
142 </select>''') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
143 self.assertEqual(self.tf.do_menu('link', size=6), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
144 '''<select name="link"> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
145 <option value="-1">- no selection -</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
146 <option selected value="1">the...</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
147 <option value="2">the...</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
148 </select>''') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
149 self.assertEqual(self.tf.do_menu('link', showid=1), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
150 '''<select name="link"> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
151 <option value="-1">- no selection -</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
152 <option selected value="1">other1: the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
153 <option value="2">other2: the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
154 </select>''') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
155 |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
156 def testMenu_multilink(self): |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
157 self.assertEqual(self.tf.do_menu('multilink', height=10), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
158 '''<select multiple name="multilink" size="10"> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
159 <option selected value="1">the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
160 <option selected value="2">the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
161 </select>''') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
162 self.assertEqual(self.tf.do_menu('multilink', size=6, height=10), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
163 '''<select multiple name="multilink" size="10"> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
164 <option selected value="1">the...</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
165 <option selected value="2">the...</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
166 </select>''') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
167 self.assertEqual(self.tf.do_menu('multilink', showid=1), |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
168 '''<select multiple name="multilink" size="2"> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
169 <option selected value="1">other1: the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
170 <option selected value="2">other2: the key</option> |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
171 </select>''') |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
172 |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
173 def suite(): |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
174 return unittest.makeSuite(NodeCase, 'test') |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
175 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
176 |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
177 # |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
178 # $Log: not supported by cvs2svn $ |
|
563
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
179 # Revision 1.1 2002/01/21 11:05:48 richard |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
180 # New tests for htmltemplate (well, it's a beginning) |
|
0f58d6a35a8b
Wrote more unit tests for htmltemplate...
Richard Jones <richard@users.sourceforge.net>
parents:
561
diff
changeset
|
181 # |
|
561
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
182 # |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
183 # |
|
13df980755fa
New tests for htmltemplate (well, it's a beginning)
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
184 # vim: set filetype=python ts=4 sw=4 et si |
