2
import os, sys, shutil, time, string
6
c = os.path.join(twistedBinDir,'') + st
7
print "Running Command: %s" % repr(c)
11
scmd(webbrowser+" "+url)
13
print "Hit enter to continue:"
17
print 'Running System Command: %s' % repr(st)
29
cmd("twistd -f %s.tap" %f)
33
cmd("twistd -g %s" %g)
37
scmd("kill `cat twistd.pid`")
38
# Give it a sec to come down.
42
print "Hit enter to continue."
46
message("Running Basic Web Test")
49
message("You should see a rather complex bunch of widgetry now.")
50
browse("http://localhost:8080/")
54
message("Running Static Web Test")
55
cmd("mktap web --static %s/../static" % twistedBinDir)
57
message("You should see an 'it worked' page now.",
58
"(depending on your browser, you may need to reload)")
59
browse("http://localhost:8080/")
60
message("This is Python CGI test output.")
61
browse("http://localhost:8080/test.cgi")
66
message("Running Distributed Web Test")
67
# make directories to stage the test
68
scmd("mkdir Personal")
70
# make & start personal server
72
cmd("mktap web --personal")
75
# make & start the user server
77
cmd("mktap web --user")
80
# browse a dead web page
81
message("This should say 'Unable to connect to distributed server'",
82
"If it doesn't finish loading, it's broken. Reload a few times..")
83
browse("http://localhost:8080/nobody.twistd")
84
# browse a live web page
85
message("This should be a bunch-of-widgets test page.")
86
browse("http://localhost:8080/%s.twistd" % username)
90
os.chdir("../Personal")
94
shutil.rmtree("Personal")
97
message("Running Telnet Test")
98
cmd("mktap telnet -p 8023 -u username -w password")
100
message("Log in with the username 'username', password 'password'.",
101
"You should be able to execute python code.",
102
"Log out with '^]close'")
103
scmd("telnet localhost 8023")
106
def runManholeTest():
107
message("Running Manhole Test")
108
cmd("mktap manhole -u username -w password")
110
message("Log in with the username 'username', password 'password'.",
111
"and bask in the l33tness of direct manipulation.")
116
message("Running Words Test")
119
message("Create yourself an account, username 'test' password 'testing'.")
120
browse("http://localhost:8080/create")
121
message("You will have to '/msg *login* testing' to log in.")
122
scmd(ircclient+" test localhost")
124
print "Hit enter to continue:"
126
message("Now let's test the 'im' interface.")
128
message("And t-im...")
132
def runRealityTest():
133
message("Running Reality Test")
134
for mapname, loginname, password in [('TRDemo', 'guest', 'guest'),
135
('Inheritance', 'Damien', 'admin'),
136
('Divunal', 'guest', 'guest')]:
137
if os.path.exists(mapname):
139
message("Log in now, username %s password %s" %
140
(repr(loginname), repr(password)))
142
message("Now again, with the TK interface.")
143
cmd("faucet --toolkit tk")
144
message("Log in again on the telnet interface.")
145
scmd("telnet localhost 4040")
146
message("Now take a look at the website, after logging in")
147
browse("http://localhost:8080/")
150
message("reality map %s not found, skipping" % mapname)
152
def runExampleTest():
153
examplesDir = twistedBinDir+'/../doc/examples'
154
os.environ['PYTHONPATH'] = '%s:%s' % (os.environ.get('PYTHONPATH') or '',
156
scmd("python %s/pbecho.py" % examplesDir)
157
twistdf("pbecho-start")
158
message("You should see a 'hello world'")
159
scmd("python %s/pbechoclient.py" % examplesDir)
164
message("Starting mail test")
167
scmd("mktap mail --domain foo.bar=dump --user postmaster=postmaster")
168
scmd("mktap --append mail.tap mail --relay 127.0.0.1,8025=dump2"
169
" --smtp 8026 --pop 8111")
171
import smtplib, poplib
172
s = smtplib.SMTP('127.0.0.1', 8026)
173
s.sendmail("m@moshez.org", ['postmaster@foo.bar'], '''\
174
Subject: How are you gentlemen?
176
All your base are belong to us
180
p = poplib.POP3('127.0.0.1', 8110)
181
p.apop('postmaster@foo.bar', 'postmaster')
182
print string.join(p.retr(1)[1], '\n')
188
message("Starting test.")
198
message('All tests run.')
201
twistedBinDir = os.path.dirname(sys.argv[0]) or '.'
203
block = sys.argv[1] == "-b"
207
webbrowser = os.environ['WEBBROWSER']
208
username = os.environ['USER']
209
ircclient = os.environ['IRCCLIENT']
211
message("Required Environment Variables:",
212
" * WEBBROWSER: a command which will run a web browser.",
213
" (If this doesn't block until the window is closed,",
214
" pass '-b' as an argument to the script.)",
215
" * IRCCLIENT: an IRC client in the style of ircii (use -b in the",
216
" same situation as above)",
217
" * USER: your UNIX username.")