-import os.path, re, urllib, time
+import os.path, re, urllib, time, cgi
import simplejson
from StringIO import StringIO
from twisted.trial import unittest
from twisted.internet import defer, reactor
from twisted.internet.task import Clock
-from twisted.web import client, error, http, html
+from twisted.web import client, error, http
from twisted.python import failure, log
from foolscap.api import fireEventually, flushEventualQueue
self._htmlname_raw = self._htmlname_unicode.encode('utf-8')
self._htmlname_urlencoded = urllib.quote(self._htmlname_raw, '')
self._htmlname_escaped = escapeToXML(self._htmlname_raw)
- self._htmlname_escaped_attr = html.escape(self._htmlname_raw)
- self._htmlname_escaped_double = escapeToXML(html.escape(self._htmlname_raw))
+ self._htmlname_escaped_attr = cgi.escape(self._htmlname_raw, quote=True)
+ self._htmlname_escaped_double = escapeToXML(cgi.escape(self._htmlname_raw, quote=True))
self.HTMLNAME_CONTENTS, n, self._htmlname_txt_uri = self.makefile(0)
foo.set_uri(self._htmlname_unicode, self._htmlname_txt_uri, self._htmlname_txt_uri)
def test_welcome(self):
d = self.GET("/")
def _check(res):
- self.failUnlessIn('Welcome to Tahoe-LAFS', res)
+ self.failUnlessIn('<title>Tahoe-LAFS - Welcome</title>', res)
self.failUnlessIn(FAVICON_MARKUP, res)
- self.failUnlessIn('href="https://tahoe-lafs.org/"', res)
+ self.failUnlessIn('<a href="status">Recent and Active Operations</a>', res)
+ self.failUnlessIn('<a href="statistics">Operational Statistics</a>', res)
+ self.failUnlessIn('<input type="hidden" name="t" value="report-incident" />', res)
res_u = res.decode('utf-8')
- self.failUnlessIn(u'<th>My nickname:</th> <td class="nickname mine">fake_nickname \u263A</td></tr>', res_u)
+ self.failUnlessIn(u'<td>fake_nickname \u263A</td>', res_u)
self.failUnlessIn(u'<div class="nickname">other_nickname \u263B</div>', res_u)
+ self.failUnlessIn(u'\u00A9 <a href="https://tahoe-lafs.org/">Tahoe-LAFS Software Foundation', res_u)
self.s.basedir = 'web/test_welcome'
fileutil.make_dirs("web/test_welcome")
self.s.uploader.helper_furl = None
return self.GET("/")
d.addCallback(_set_no_helper)
- d.addCallback(lambda res:
- self.failUnlessIn('Connected to helper?: <span>not configured</span>', res))
+ def _check_no_helper(res):
+ html = res.replace('\n', ' ')
+ self.failUnless(re.search('<div class="status-indicator connected-not-configured"></div>[ ]*Helper', html), res)
+ d.addCallback(_check_no_helper)
# enable helper, not connected
def _set_helper_not_connected(ign):
self.s.uploader.helper_connected = False
return self.GET("/")
d.addCallback(_set_helper_not_connected)
- d.addCallback(lambda res:
- self.failUnlessIn('Connected to helper?: <span>no</span>', res))
+ def _check_helper_not_connected(res):
+ html = res.replace('\n', ' ')
+ self.failUnless(re.search('<div class="status-indicator connected-no"></div>[ ]*Helper', html), res)
+ d.addCallback(_check_helper_not_connected)
# enable helper, connected
def _set_helper_connected(ign):
self.s.uploader.helper_connected = True
return self.GET("/")
d.addCallback(_set_helper_connected)
- d.addCallback(lambda res:
- self.failUnlessIn('Connected to helper?: <span>yes</span>', res))
+ def _check_helper_connected(res):
+ html = res.replace('\n', ' ')
+ self.failUnless(re.search('<div class="status-indicator connected-yes"></div>[ ]*Helper', html), res)
+ d.addCallback(_check_helper_connected)
return d
def test_storage(self):
ret_num = h.list_all_retrieve_statuses()[0].get_counter()
d = self.GET("/status", followRedirect=True)
def _check(res):
- self.failUnlessIn('Upload and Download Status', res)
+ self.failUnlessIn('Recent and Active Operations', res)
self.failUnlessIn('"down-%d"' % dl_num, res)
self.failUnlessIn('"up-%d"' % ul_num, res)
self.failUnlessIn('"mapupdate-%d"' % mu_num, res)
# We should have a form to create a file, with radio buttons that allow
# the user to toggle whether it is a CHK/LIT (default), SDMF, or MDMF file.
self.failUnlessIn('name="t" value="upload"', html)
- self.failUnlessIn('input checked="checked" type="radio" id="upload-chk" value="chk" name="format"', html)
- self.failUnlessIn('input type="radio" id="upload-sdmf" value="sdmf" name="format"', html)
- self.failUnlessIn('input type="radio" id="upload-mdmf" value="mdmf" name="format"', html)
+ self.failUnless(re.search('<input [^/]*id="upload-chk"', html), html)
+ self.failUnless(re.search('<input [^/]*id="upload-sdmf"', html), html)
+ self.failUnless(re.search('<input [^/]*id="upload-mdmf"', html), html)
# We should also have the ability to create a mutable directory, with
# radio buttons that allow the user to toggle whether it is an SDMF (default)
# or MDMF directory.
self.failUnlessIn('name="t" value="mkdir"', html)
- self.failUnlessIn('input checked="checked" type="radio" id="mkdir-sdmf" value="sdmf" name="format"', html)
- self.failUnlessIn('input type="radio" id="mkdir-mdmf" value="mdmf" name="format"', html)
+ self.failUnless(re.search('<input [^/]*id="mkdir-sdmf"', html), html)
+ self.failUnless(re.search('<input [^/]*id="mkdir-mdmf"', html), html)
self.failUnlessIn(FAVICON_MARKUP, html)
d = self.GET("/")
def _after_get_welcome_page(res):
MKDIR_BUTTON_RE = re.compile(
- '<form action="([^"]*)" method="post".*?'
- '<input type="hidden" name="t" value="([^"]*)" />'
- '<input type="hidden" name="([^"]*)" value="([^"]*)" />'
- '<input type="submit" value="Create a directory" />',
- re.I)
- mo = MKDIR_BUTTON_RE.search(res)
+ '<form action="([^"]*)" method="post".*'
+ '<input type="hidden" name="t" value="([^"]*)" />[ ]*'
+ '<input type="hidden" name="([^"]*)" value="([^"]*)" />[ ]*'
+ '<input type="submit" class="btn" value="Create a directory[^"]*" />')
+ html = res.replace('\n', ' ')
+ mo = MKDIR_BUTTON_RE.search(html)
+ self.failUnless(mo, html)
formaction = mo.group(1)
formt = mo.group(2)
formaname = mo.group(3)