WIP porting test_status.py.

This commit is contained in:
Itamar Turner-Trauring 2020-12-16 14:13:46 -05:00
parent 67c0a4ac84
commit b5f2afe39c
2 changed files with 9 additions and 8 deletions

View File

@ -90,7 +90,7 @@ class FakeNodeMaker(NodeMaker):
return FakeMutableFileNode(None, None,
self.encoding_params, None,
self.all_contents).init_from_cap(cap)
def create_mutable_file(self, contents="", keysize=None,
def create_mutable_file(self, contents=b"", keysize=None,
version=SDMF_VERSION):
n = FakeMutableFileNode(None, None, self.encoding_params, None,
self.all_contents)
@ -105,7 +105,7 @@ class FakeUploader(service.Service):
d = uploadable.get_size()
d.addCallback(lambda size: uploadable.read(size))
def _got_data(datav):
data = "".join(datav)
data = b"".join(datav)
n = create_chk_filenode(data, self.all_contents)
ur = upload.UploadResults(file_size=len(data),
ciphertext_fetched=0,
@ -130,9 +130,9 @@ def build_one_ds():
ds = DownloadStatus("storage_index", 1234)
now = time.time()
serverA = StubServer(hashutil.tagged_hash("foo", "serverid_a")[:20])
serverB = StubServer(hashutil.tagged_hash("foo", "serverid_b")[:20])
storage_index = hashutil.storage_index_hash("SI")
serverA = StubServer(hashutil.tagged_hash(b"foo", b"serverid_a")[:20])
serverB = StubServer(hashutil.tagged_hash(b"foo", b"serverid_b")[:20])
storage_index = hashutil.storage_index_hash(b"SI")
e0 = ds.add_segment_request(0, now)
e0.activate(now+0.5)
e0.deliver(now+1, 0, 100, 0.5) # when, start,len, decodetime

View File

@ -1,3 +1,4 @@
from past.builtins import long, unicode
import pprint
import itertools
@ -1297,6 +1298,7 @@ class Status(MultiFormatResource):
except ValueError:
raise WebError("no '-' in '{}'".format(path))
count = int(count_s)
stype = unicode(stype, "ascii")
if stype == "up":
for s in itertools.chain(h.list_all_upload_statuses(),
h.list_all_helper_statuses()):
@ -1335,7 +1337,7 @@ class Status(MultiFormatResource):
active = [s
for s in self._get_all_statuses()
if s.get_active()]
active.sort(lambda a, b: cmp(a.get_started(), b.get_started()))
active.sort(key=lambda a: a.get_started())
active.reverse()
return active
@ -1343,7 +1345,7 @@ class Status(MultiFormatResource):
recent = [s
for s in self._get_all_statuses()
if not s.get_active()]
recent.sort(lambda a, b: cmp(a.get_started(), b.get_started()))
recent.sort(key=lambda a: a.get_started())
recent.reverse()
return recent
@ -1373,7 +1375,6 @@ class StatusElement(Element):
started_s = render_time(op.get_started())
result["started"] = started_s
si_s = base32.b2a_or_none(op.get_storage_index())
if si_s is None:
si_s = "(None)"