mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 08:25:35 +00:00
Another passing test on Python 3.
This commit is contained in:
parent
0534979e61
commit
74c08883f5
@ -361,18 +361,19 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
|
|||||||
# make sure directory listing tolerates unknown nodes
|
# make sure directory listing tolerates unknown nodes
|
||||||
d.addCallback(lambda ign: self.GET(self.rooturl))
|
d.addCallback(lambda ign: self.GET(self.rooturl))
|
||||||
def _check_directory_html(res, expected_type_suffix):
|
def _check_directory_html(res, expected_type_suffix):
|
||||||
pattern = re.compile(r'<td>\?%s</td>[ \t\n\r]*'
|
pattern = re.compile(br'<td>\?%s</td>[ \t\n\r]*'
|
||||||
'<td>%s</td>' % (expected_type_suffix, str(name)),
|
b'<td>%s</td>' % (
|
||||||
|
expected_type_suffix, name.encode("ascii")),
|
||||||
re.DOTALL)
|
re.DOTALL)
|
||||||
self.failUnless(re.search(pattern, res), res)
|
self.failUnless(re.search(pattern, res), res)
|
||||||
# find the More Info link for name, should be relative
|
# find the More Info link for name, should be relative
|
||||||
mo = re.search(r'<a href="([^"]+)">More Info</a>', res)
|
mo = re.search(br'<a href="([^"]+)">More Info</a>', res)
|
||||||
info_url = mo.group(1)
|
info_url = mo.group(1)
|
||||||
self.failUnlessReallyEqual(info_url, "%s?t=info" % (str(name),))
|
self.failUnlessReallyEqual(info_url, b"%s?t=info" % (name.encode("ascii"),))
|
||||||
if immutable:
|
if immutable:
|
||||||
d.addCallback(_check_directory_html, "-IMM")
|
d.addCallback(_check_directory_html, b"-IMM")
|
||||||
else:
|
else:
|
||||||
d.addCallback(_check_directory_html, "")
|
d.addCallback(_check_directory_html, b"")
|
||||||
|
|
||||||
d.addCallback(lambda ign: self.GET(self.rooturl+"?t=json"))
|
d.addCallback(lambda ign: self.GET(self.rooturl+"?t=json"))
|
||||||
def _check_directory_json(res, expect_rw_uri):
|
def _check_directory_json(res, expect_rw_uri):
|
||||||
@ -392,7 +393,6 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
|
|||||||
d.addCallback(_check_directory_json, expect_rw_uri=not immutable)
|
d.addCallback(_check_directory_json, expect_rw_uri=not immutable)
|
||||||
|
|
||||||
def _check_info(res, expect_rw_uri, expect_ro_uri):
|
def _check_info(res, expect_rw_uri, expect_ro_uri):
|
||||||
self.failUnlessIn("Object Type: <span>unknown</span>", res)
|
|
||||||
if expect_rw_uri:
|
if expect_rw_uri:
|
||||||
self.failUnlessIn(unknown_rwcap, res)
|
self.failUnlessIn(unknown_rwcap, res)
|
||||||
if expect_ro_uri:
|
if expect_ro_uri:
|
||||||
@ -402,6 +402,8 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
|
|||||||
self.failUnlessIn(unknown_rocap, res)
|
self.failUnlessIn(unknown_rocap, res)
|
||||||
else:
|
else:
|
||||||
self.failIfIn(unknown_rocap, res)
|
self.failIfIn(unknown_rocap, res)
|
||||||
|
res = unicode(res, "utf-8")
|
||||||
|
self.failUnlessIn("Object Type: <span>unknown</span>", res)
|
||||||
self.failIfIn("Raw data as", res)
|
self.failIfIn("Raw data as", res)
|
||||||
self.failIfIn("Directory writecap", res)
|
self.failIfIn("Directory writecap", res)
|
||||||
self.failIfIn("Checker Operations", res)
|
self.failIfIn("Checker Operations", res)
|
||||||
@ -413,7 +415,7 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
|
|||||||
|
|
||||||
d.addCallback(lambda ign: self.GET(expected_info_url))
|
d.addCallback(lambda ign: self.GET(expected_info_url))
|
||||||
d.addCallback(_check_info, expect_rw_uri=False, expect_ro_uri=False)
|
d.addCallback(_check_info, expect_rw_uri=False, expect_ro_uri=False)
|
||||||
d.addCallback(lambda ign: self.GET("%s/%s?t=info" % (self.rooturl, str(name))))
|
d.addCallback(lambda ign: self.GET("%s/%s?t=info" % (self.rooturl, name)))
|
||||||
d.addCallback(_check_info, expect_rw_uri=False, expect_ro_uri=True)
|
d.addCallback(_check_info, expect_rw_uri=False, expect_ro_uri=True)
|
||||||
|
|
||||||
def _check_json(res, expect_rw_uri):
|
def _check_json(res, expect_rw_uri):
|
||||||
@ -445,9 +447,9 @@ class Grid(GridTestMixin, WebErrorMixin, ShouldFailMixin, testutil.ReallyEqualMi
|
|||||||
# or not future_node was immutable.
|
# or not future_node was immutable.
|
||||||
d.addCallback(lambda ign: self.GET(self.rourl))
|
d.addCallback(lambda ign: self.GET(self.rourl))
|
||||||
if immutable:
|
if immutable:
|
||||||
d.addCallback(_check_directory_html, "-IMM")
|
d.addCallback(_check_directory_html, b"-IMM")
|
||||||
else:
|
else:
|
||||||
d.addCallback(_check_directory_html, "-RO")
|
d.addCallback(_check_directory_html, b"-RO")
|
||||||
|
|
||||||
d.addCallback(lambda ign: self.GET(self.rourl+"?t=json"))
|
d.addCallback(lambda ign: self.GET(self.rourl+"?t=json"))
|
||||||
d.addCallback(_check_directory_json, expect_rw_uri=False)
|
d.addCallback(_check_directory_json, expect_rw_uri=False)
|
||||||
|
@ -1464,7 +1464,7 @@ class UnknownNodeHandler(Resource, object):
|
|||||||
|
|
||||||
@render_exception
|
@render_exception
|
||||||
def render_GET(self, req):
|
def render_GET(self, req):
|
||||||
t = get_arg(req, b"t", b"").strip()
|
t = unicode(get_arg(req, "t", "").strip(), "ascii")
|
||||||
if t == "info":
|
if t == "info":
|
||||||
return MoreInfo(self.node)
|
return MoreInfo(self.node)
|
||||||
if t == "json":
|
if t == "json":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user