File: testexamples.py

package info (click to toggle)
nevow 0.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,264 kB
  • ctags: 5,311
  • sloc: python: 21,511; ansic: 136; sh: 65; xml: 42; makefile: 32; sql: 5
file content (194 lines) | stat: -rw-r--r-- 5,951 bytes parent folder | download | duplicates (5)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
from nevow import livetest


all_suites = dict(
    most_basic=[
        ('visit', '/most_basic/', ''),
        ('assert', 'foo', 'foo'),
        ('follow', 'foo', ''),
        ('assert', 'heading', 'You are in Foo'),
        ('follow', 'baz', ''),
        ('assert', 'heading', 'You are in Baz')],
    hellostan=[
        ('visit', '/hellostan/', ''),
        ('assert', 'body', 'Welcome to the wonderful world of Nevow!')],
    hellohtml=[
        ('visit', '/hellohtml/', ''),
        ('assert', 'body', 'Welcome to the wonderful world of Nevow!')],
    simple=[
        ('visit', '/simple/', ''),
        ('assert', 'count', '1'),
        ('visit', '/simple/', ''),
        ('assert', 'count', '2'),
        ('visit', '/simple/reset', ''),
        ('assert', 'reset', 'Count reset')],
    simplehtml=[
        ('visit', '/simplehtml/', ''),
        ('assert', 'count', '1'),
        ('visit', '/simplehtml/', ''),
        ('assert', 'count', '2'),
        ('visit', '/simplehtml/reset', ''),
        ('assert', 'reset', 'Count reset')],
    tables=[
        ('visit', '/tablehtml/', ''),
        ('assert', 'firstHeader', 'First Column'),
        ('assert', 'secondHeader', 'Second Column'),
        ('assert', 'firstFooter', 'First Footer'),
        ('assert', 'secondFooter', 'Second Footer')],
    disktemplates_stan=[
        ('visit', '/disktemplates_stan/', ''),
        ('assert', 'header', 'Welcome')],
    disktemplates=[
        ('visit', '/disktemplates/', ''),
        ('assert', 'header', 'Welcome')],
    children=[
        ('visit', '/children/', ''),
        ('follow', 'foo', ''),
        ('assert', 'name', 'foo'),
        ('follow', 'child', ''),
        ('assert', 'parentName', 'foo'),
        ('visit', '/children/', ''),
        ('follow', 'bar', ''),
        ('assert', 'name', 'bar'),
        ('follow', 'child', ''),
        ('assert', 'parentName', 'bar'),
        ('visit', '/children/', ''),
        ('follow', 'd1', ''),
        ('assert', 'name', '1'),
        ('follow', 'child', ''),
        ('assert', 'parentName', '1'),
        ('visit', '/children/', ''),
        ('follow', 'd2', ''),
        ('assert', 'name', '2'),
        ('follow', 'child', ''),
        ('assert', 'parentName', '2'),
        ('visit', '/children/', ''),
        ('follow', 'd3', ''),
        ('assert', 'name', '3'),
        ('follow', 'child', ''),
        ('assert', 'parentName', '3'),
        ('visit', '/children/', ''),
        ('follow', 'd4', ''),
        ('assert', 'name', '4'),
        ('visit', '/children/', ''),
        ('follow', 'd5', ''),
        ('assert', 'name', '5'),
        ('visit', '/children/', ''),
        ('follow', 'd6/7', ''),
        ('assert', 'name', '6/7')],
    objcontainer=[
        ('visit', '/objcontainer/', ''),
        ],
    manualform=[
        ('visit', '/manualform/', ''),
        ],
    advanced_manualform=[
        ('visit', '/advanced_manualform/', ''),
        ],
    formpost=[
        ('visit', '/formpost/', ''),
        ],
    formpost2=[
        ('visit', '/formpost2/', ''),
        ],
    db=[
        ('visit', '/db/', ''),
        ],
    http_auth=[
        ('visit', '/http_auth/', ''),
        ],
    guarded=[
        ('visit', '/guarded/', ''),
        ],
    guarded2=[
        ('visit', '/guarded2/', ''),
        ],
    logout_guard=[
        ('visit', '/logout_guard/', ''),
        ],
    logout_guard2=[
        ('visit', '/logout_guard2/', ''),
        ],
    customform=[
        ('visit', '/customform/', ''),
        ],
    formbuilder=[
        ('visit', '/formbuilder/', ''),
        ],
    simple_irenderer=[
        ('visit', '/simple_irenderer/', ''),
        ],
    irenderer=[
        ('visit', '/irenderer/', ''),
        ],
    tree=[
        ('visit', '/tree/', ''),
        ],
    i18n=[
        ('visit', '/i18n/', ''),
        ],
    xmli18n=[
        ('visit', '/xmli18n/', ''),
        ],
    # Tag Library Examples
    calendar=[
        ('visit', '/calendar/', ''),
        ],
    tabbed=[
        ('visit', '/tabbed/', ''),
        ],
    progress=[
        ('visit', '/progress/', ''),
        ],
    ## TODO: There are many more tests to be written here, but it is boring
)

live_suites = dict(
    ## Now the fun stuff: The livepage example tests.
liveanimal=[
        ('visit', '/liveanimal/?fresh=true', ''),
        ('assert', 'question', 'I give up. What is the animal, and what question describes it?'),
        ('submit', 'new-question', {'animal': "Monkey", 'new-question': 'is it crazy'}),
        ('assert', 'question', 'is it crazy'),
        ('click', 'yes-response', ''),
        ('assert', 'question', 'Is it Monkey?'),
        ('click', 'no-response', ''),
        ('assert', 'question', 'I give up. What is the animal, and what question describes it?'),
        ('submit', 'new-question', {'animal': 'Mongoose', 'new-question': 'does it eat snakes'}),
        ('assert', 'question', 'is it crazy'),
        ('click', 'yes-response', ''),
        ('assert', 'question', 'does it eat snakes'),
        ('click', 'yes-response', ''),
        ('assert', 'question', 'Is it Mongoose?'),
        ('click', 'yes-response', ''),
        ('assert', 'question', 'I win!'),
        ('click', 'start-over', ''),
        ('assert', 'question', 'is it crazy')
    ],
#chatola=[
#    ('visit', '/chatola/', ''),
#    ('submit', 'topicform', {'change-topic': 'Hello, world!'}),
#    ('submit', 'inputform', {'inputline': 'Greetings humans of earth'}),
#    ('submit', 'inputform', {'inputline': 'Take me to your leader'}),
#]
)



def createResource(whichOne=None):
    if whichOne is None:
        suite = []
        for subsuite in all_suites.values():
            suite.extend(subsuite)
        return livetest.Tester(suite)

    return livetest.Tester(all_suites[whichOne])


def createLiveSuite(whichOne=None):
    suite = []
    for subsuite in live_suites.values():
        suite.extend(subsuite)
    return livetest.Tester(suite)