From e28752fa5adf3c1eb36f68b070020d5f1aad798f Mon Sep 17 00:00:00 2001 From: Nikolaos Korasidis Date: Tue, 23 Sep 2014 05:09:22 +0300 Subject: [PATCH] Abstract kbucket unit tests from GUID implementation. --- test/test_kbucket.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/test_kbucket.py b/test/test_kbucket.py index 24048b71b..716fcff72 100644 --- a/test/test_kbucket.py +++ b/test/test_kbucket.py @@ -1,14 +1,27 @@ import random import unittest -from node import kbucket, contact, constants +from node import constants, kbucket + + +class AbstractGUID(object): + def __init__(self, guid, address): + self.guid = guid + self.address = address + + def __eq__(self, other): + if isinstance(other, self.__class__): + return self.guid == other.guid + elif isinstance(other, str): + return self.guid == other + return False class Test(unittest.TestCase): @staticmethod def _mk_contact_by_num(i): - return contact.Contact(str(i), 'http://foo/%d' % i) + return AbstractGUID(str(i), 'http://foo/%d' % i) @classmethod def setUpClass(cls):