mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-13 05:43:03 +00:00
Add more docstrings; add a test hook.
In place of nevow's renderSynchronously, I think it'll be good enough to return the Element directly so it can be flattened. It still gets flattened with a None request, which might need to change.
This commit is contained in:
parent
e2c2c30574
commit
e670bb5d3b
src/allmydata
@ -11,6 +11,7 @@ from testtools.matchers import (
|
||||
from twisted.internet import defer, address
|
||||
from twisted.python import log
|
||||
from twisted.python.filepath import FilePath
|
||||
from twisted.web.template import flattenString
|
||||
|
||||
from foolscap.api import Tub, Referenceable, fireEventually, flushEventualQueue
|
||||
from twisted.application import service
|
||||
@ -592,7 +593,12 @@ class SystemTest(SystemTestMixin, AsyncTestCase):
|
||||
# now check the web status, make sure it renders without error
|
||||
ir = introweb.IntroducerRoot(self.parent)
|
||||
self.parent.nodeid = "NODEID"
|
||||
text = ir.renderSynchronously().decode("utf-8")
|
||||
log.msg("_check1 done")
|
||||
return flattenString(None, ir._create_element())
|
||||
d.addCallback(_check1)
|
||||
|
||||
def _check2(flattened_bytes):
|
||||
text = flattened_bytes.decode("utf-8")
|
||||
self.assertIn(NICKNAME % "0", text) # a v2 client
|
||||
self.assertIn(NICKNAME % "1", text) # another v2 client
|
||||
for i in range(NUM_STORAGE):
|
||||
@ -601,8 +607,8 @@ class SystemTest(SystemTestMixin, AsyncTestCase):
|
||||
# make sure there isn't a double-base32ed string too
|
||||
self.assertNotIn(idlib.nodeid_b2a(printable_serverids[i]), text,
|
||||
(i,printable_serverids[i],text))
|
||||
log.msg("_check1 done")
|
||||
d.addCallback(_check1)
|
||||
log.msg("_check2 done")
|
||||
d.addCallback(_check2)
|
||||
|
||||
# force an introducer reconnect, by shutting down the Tub it's using
|
||||
# and starting a new Tub (with the old introducer). Everybody should
|
||||
|
@ -16,6 +16,12 @@ from allmydata.web.common import (
|
||||
|
||||
|
||||
class IntroducerRoot(MultiFormatResource):
|
||||
"""
|
||||
A ``Resource`` intended as the root resource for introducers.
|
||||
|
||||
:param _IntroducerNode introducer_node: The introducer node to template
|
||||
information about.
|
||||
"""
|
||||
|
||||
def __init__(self, introducer_node):
|
||||
super(IntroducerRoot, self).__init__()
|
||||
@ -27,11 +33,24 @@ class IntroducerRoot(MultiFormatResource):
|
||||
for filen in os.listdir(static_dir):
|
||||
self.putChild(filen, static.File(os.path.join(static_dir, filen)))
|
||||
|
||||
def _create_element(self):
|
||||
"""
|
||||
Create a ``IntroducerRootElement`` which can be flattened into an HTML
|
||||
response.
|
||||
"""
|
||||
return IntroducerRootElement(
|
||||
self.introducer_node, self.introducer_service)
|
||||
|
||||
def render_HTML(self, req):
|
||||
return renderElement(req, IntroducerRootElement(
|
||||
self.introducer_node, self.introducer_service))
|
||||
"""
|
||||
Render an HTML template describing this introducer node.
|
||||
"""
|
||||
return renderElement(req, self._create_element())
|
||||
|
||||
def render_JSON(self, req):
|
||||
"""
|
||||
Render JSON describing this introducer node.
|
||||
"""
|
||||
res = {}
|
||||
|
||||
counts = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user