mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
Test and bugfix for LiteralFileNode equality.
This commit is contained in:
parent
66c6522325
commit
e3a9f5fa75
@ -32,16 +32,15 @@ class _ImmutableFileNodeBase(object):
|
||||
|
||||
def __hash__(self):
|
||||
return self.u.__hash__()
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, _ImmutableFileNodeBase):
|
||||
return self.u.__eq__(other.u)
|
||||
return self.u == other.u
|
||||
else:
|
||||
return False
|
||||
|
||||
def __ne__(self, other):
|
||||
if isinstance(other, _ImmutableFileNodeBase):
|
||||
return self.u.__eq__(other.u)
|
||||
else:
|
||||
return True
|
||||
return not self == other
|
||||
|
||||
|
||||
class LiteralFileNode(_ImmutableFileNodeBase):
|
||||
|
@ -26,6 +26,7 @@ from allmydata.util.consumer import download_to_data
|
||||
from allmydata.interfaces import NotEnoughSharesError
|
||||
from allmydata.immutable.upload import Data
|
||||
from allmydata.immutable.downloader import finder
|
||||
from allmydata.immutable.literal import LiteralFileNode
|
||||
|
||||
from .no_network import (
|
||||
NoNetworkServer,
|
||||
@ -340,6 +341,24 @@ class Test(GridTestMixin, unittest.TestCase, common.ShouldFailMixin):
|
||||
return d
|
||||
|
||||
|
||||
class LiteralFileNodeTests(unittest.TestCase):
|
||||
"""Tests for LiteralFileNode."""
|
||||
|
||||
def test_equality(self):
|
||||
"""LiteralFileNodes are equal iff they have the same URI."""
|
||||
uri1 = uri.LiteralFileURI(b"1")
|
||||
uri2 = uri.LiteralFileURI(b"2")
|
||||
lfn1 = LiteralFileNode(uri1)
|
||||
lfn1b = LiteralFileNode(uri1)
|
||||
lfn2 = LiteralFileNode(uri2)
|
||||
self.assertTrue(lfn1 == lfn1b)
|
||||
self.assertFalse(lfn1 != lfn1b)
|
||||
self.assertTrue(lfn1 != lfn2)
|
||||
self.assertFalse(lfn1 == lfn2)
|
||||
self.assertTrue(lfn1 != 300)
|
||||
self.assertFalse(lfn1 == 300)
|
||||
|
||||
|
||||
# XXX extend these tests to show bad behavior of various kinds from servers:
|
||||
# raising exception from each remove_foo() method, for example
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user