mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 05:28:04 +00:00
Add test coverage for packing UnknownNode with missing read-only URI.
This commit is contained in:
parent
66cd68d325
commit
36e53caaeb
@ -1475,6 +1475,30 @@ class Packing(testutil.ReallyEqualMixin, unittest.TestCase):
|
||||
kids[str(name)] = (nm.create_from_cap(caps[name]), {})
|
||||
return kids
|
||||
|
||||
def test_pack_unpack_unknown(self):
|
||||
"""
|
||||
Minimal testing for roundtripping unknown URIs.
|
||||
"""
|
||||
nm = NodeMaker(None, None, None, None, None, {"k": 3, "n": 10}, None, None)
|
||||
fn = MinimalFakeMutableFile()
|
||||
# UnknownNode has massively complex rules about when it's an error.
|
||||
# Just force it not to be an error.
|
||||
unknown_rw = UnknownNode(b"whatevs://write", None)
|
||||
unknown_rw.error = None
|
||||
unknown_ro = UnknownNode(None, b"whatevs://readonly")
|
||||
unknown_ro.error = None
|
||||
kids = {
|
||||
"unknown_rw": (unknown_rw, {}),
|
||||
"unknown_ro": (unknown_ro, {})
|
||||
}
|
||||
packed = dirnode.pack_children(kids, fn.get_writekey(), deep_immutable=False)
|
||||
|
||||
write_uri = b"URI:SSK-RO:e3mdrzfwhoq42hy5ubcz6rp3o4:ybyibhnp3vvwuq2vaw2ckjmesgkklfs6ghxleztqidihjyofgw7q"
|
||||
filenode = nm.create_from_cap(write_uri)
|
||||
dn = dirnode.DirectoryNode(filenode, nm, None)
|
||||
unkids = dn._unpack_contents(packed)
|
||||
self.assertEqual(kids, unkids)
|
||||
|
||||
@given(text(min_size=1, max_size=20))
|
||||
def test_pack_unpack_unicode_hypothesis(self, name):
|
||||
"""
|
||||
|
@ -182,3 +182,11 @@ class UnknownNode(object):
|
||||
|
||||
def check_and_repair(self, monitor, verify, add_lease):
|
||||
return defer.succeed(None)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, UnknownNode):
|
||||
return False
|
||||
return other.ro_uri == self.ro_uri and other.rw_uri == self.rw_uri
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
Loading…
Reference in New Issue
Block a user