mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
A little progress on passing tests.
This commit is contained in:
parent
ade4a5a543
commit
1088e5368d
@ -616,7 +616,7 @@ class Checker(log.PrefixingLogMixin):
|
||||
d.addCallback(_got_ueb)
|
||||
|
||||
def _discard_result(r):
|
||||
assert isinstance(r, str), r
|
||||
assert isinstance(r, bytes), r
|
||||
# to free up the RAM
|
||||
return None
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
from future.utils import PY2
|
||||
from past.builtins import unicode
|
||||
|
||||
import json
|
||||
import os.path, shutil
|
||||
@ -7,7 +9,14 @@ from bs4 import BeautifulSoup
|
||||
from twisted.trial import unittest
|
||||
from twisted.internet import defer
|
||||
|
||||
from nevow.inevow import IRequest
|
||||
# We need to use `nevow.inevow.IRequest` for now for compatibility
|
||||
# with the code in web/common.py. Once nevow bits are gone from
|
||||
# web/common.py, we can use `twisted.web.iweb.IRequest` here.
|
||||
if PY2:
|
||||
from nevow.inevow import IRequest
|
||||
else:
|
||||
from twisted.web.iweb import IRequest
|
||||
|
||||
from zope.interface import implementer
|
||||
from twisted.web.server import Request
|
||||
from twisted.web.test.requesthelper import DummyChannel
|
||||
@ -102,7 +111,7 @@ class FakeCheckResults(object):
|
||||
|
||||
def get_corrupt_shares(self):
|
||||
# returns a list of (IServer, storage_index, sharenum)
|
||||
return [(FakeServer(), "<fake-si>", 0)]
|
||||
return [(FakeServer(), b"<fake-si>", 0)]
|
||||
|
||||
|
||||
@implementer(ICheckAndRepairResults)
|
||||
@ -141,13 +150,13 @@ class WebResultsRendering(unittest.TestCase):
|
||||
sb = StorageFarmBroker(True, None, EMPTY_CLIENT_CONFIG)
|
||||
# s.get_name() (the "short description") will be "v0-00000000".
|
||||
# s.get_longname() will include the -long suffix.
|
||||
servers = [("v0-00000000-long", "\x00"*20, "peer-0"),
|
||||
("v0-ffffffff-long", "\xff"*20, "peer-f"),
|
||||
("v0-11111111-long", "\x11"*20, "peer-11")]
|
||||
servers = [(b"v0-00000000-long", b"\x00"*20, "peer-0"),
|
||||
(b"v0-ffffffff-long", b"\xff"*20, "peer-f"),
|
||||
(b"v0-11111111-long", b"\x11"*20, "peer-11")]
|
||||
for (key_s, binary_tubid, nickname) in servers:
|
||||
server_id = key_s
|
||||
tubid_b32 = base32.b2a(binary_tubid)
|
||||
furl = "pb://%s@nowhere/fake" % tubid_b32
|
||||
furl = b"pb://%s@nowhere/fake" % tubid_b32
|
||||
ann = { "version": 0,
|
||||
"service-name": "storage",
|
||||
"anonymous-storage-FURL": furl,
|
||||
@ -174,11 +183,11 @@ class WebResultsRendering(unittest.TestCase):
|
||||
lcr = web_check_results.LiteralCheckResultsRendererElement()
|
||||
|
||||
html = self.render_element(lcr)
|
||||
self.failUnlessIn("Literal files are always healthy", html)
|
||||
self.failUnlessIn(b"Literal files are always healthy", html)
|
||||
|
||||
html = self.render_element(lcr, args={"return_to": ["FOOURL"]})
|
||||
self.failUnlessIn("Literal files are always healthy", html)
|
||||
self.failUnlessIn('<a href="FOOURL">Return to file.</a>', html)
|
||||
self.failUnlessIn(b"Literal files are always healthy", html)
|
||||
self.failUnlessIn(b'<a href="FOOURL">Return to file.</a>', html)
|
||||
|
||||
c = self.create_fake_client()
|
||||
lcr = web_check_results.LiteralCheckResultsRenderer(c)
|
||||
@ -196,7 +205,7 @@ class WebResultsRendering(unittest.TestCase):
|
||||
serverid_f = "\xff"*20
|
||||
server_1 = sb.get_stub_server(serverid_1)
|
||||
server_f = sb.get_stub_server(serverid_f)
|
||||
u = uri.CHKFileURI("\x00"*16, "\x00"*32, 3, 10, 1234)
|
||||
u = uri.CHKFileURI(b"\x00"*16, b"\x00"*32, 3, 10, 1234)
|
||||
data = { "count_happiness": 8,
|
||||
"count_shares_needed": 3,
|
||||
"count_shares_expected": 9,
|
||||
@ -301,9 +310,9 @@ class WebResultsRendering(unittest.TestCase):
|
||||
def test_check_and_repair(self):
|
||||
c = self.create_fake_client()
|
||||
sb = c.storage_broker
|
||||
serverid_1 = "\x00"*20
|
||||
serverid_f = "\xff"*20
|
||||
u = uri.CHKFileURI("\x00"*16, "\x00"*32, 3, 10, 1234)
|
||||
serverid_1 = b"\x00"*20
|
||||
serverid_f = b"\xff"*20
|
||||
u = uri.CHKFileURI(b"\x00"*16, b"\x00"*32, 3, 10, 1234)
|
||||
|
||||
data = { "count_happiness": 5,
|
||||
"count_shares_needed": 3,
|
||||
@ -419,7 +428,7 @@ class WebResultsRendering(unittest.TestCase):
|
||||
|
||||
|
||||
def test_deep_check_renderer(self):
|
||||
status = check_results.DeepCheckResults("fake-root-si")
|
||||
status = check_results.DeepCheckResults(b"fake-root-si")
|
||||
status.add_check(
|
||||
FakeCheckResults("<unhealthy/unrecoverable>", False, False),
|
||||
(u"fake", u"unhealthy", u"unrecoverable")
|
||||
@ -512,7 +521,7 @@ class WebResultsRendering(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_deep_check_and_repair_renderer(self):
|
||||
status = check_results.DeepCheckAndRepairResults("")
|
||||
status = check_results.DeepCheckAndRepairResults(b"")
|
||||
|
||||
status.add_check_and_repair(
|
||||
FakeCheckAndRepairResults("attempted/success", True, True),
|
||||
@ -676,8 +685,8 @@ class BalancingAct(GridTestMixin, unittest.TestCase):
|
||||
c0.encoding_params['n'] = 4
|
||||
c0.encoding_params['k'] = 3
|
||||
|
||||
DATA = "data" * 100
|
||||
d = c0.upload(Data(DATA, convergence=""))
|
||||
DATA = b"data" * 100
|
||||
d = c0.upload(Data(DATA, convergence=b""))
|
||||
def _stash_immutable(ur):
|
||||
self.imm = c0.create_node_from_uri(ur.get_uri())
|
||||
self.uri = self.imm.get_uri()
|
||||
@ -834,8 +843,8 @@ class TooParallel(GridTestMixin, unittest.TestCase):
|
||||
"max_segment_size": 5,
|
||||
}
|
||||
self.uris = {}
|
||||
DATA = "data" * 100 # 400/5 = 80 blocks
|
||||
return self.c0.upload(Data(DATA, convergence=""))
|
||||
DATA = b"data" * 100 # 400/5 = 80 blocks
|
||||
return self.c0.upload(Data(DATA, convergence=b""))
|
||||
d.addCallback(_start)
|
||||
def _do_check(ur):
|
||||
n = self.c0.create_node_from_uri(ur.get_uri())
|
||||
|
Loading…
Reference in New Issue
Block a user