Skip to content

Commit

Permalink
Abstract kbucket unit tests from GUID implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Renelvon committed Sep 23, 2014
1 parent eae502f commit e28752f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/test_kbucket.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit e28752f

Please sign in to comment.