def test_exists(self): distributedHT = LocalMemoryDHT(8, 10) self.__insert(distributedHT) for case in self.__cases: self.assertTrue(distributedHT.exists(case.hashValue)) for case in self.__nonExistingCases: self.assertFalse(distributedHT.exists(case.hashValue))
def test_countCollision(self): distributedHT = LocalMemoryDHT(8, 10) self.__insert(distributedHT) expectedHashCount = 2 expectedValueCount = 4 expectedTotalCount = 9 hashCount, valueCount, totalCount = distributedHT.countCollision() self.assertEqual(hashCount, expectedHashCount) self.assertEqual(valueCount, expectedValueCount) self.assertEqual(totalCount, expectedTotalCount)
def test_calculateCollision(self): distributedHT = LocalMemoryDHT(8, 10) self.__insert(distributedHT) expected_collision = 4 / 9.0 self.assertEqual(distributedHT.calculateCollision(), expected_collision)
def test_read(self): distributedHT = LocalMemoryDHT(8, 10) for case in self.__cases: distributedHT.insert(case.hashValue) self.assertEqual(distributedHT.read(case.hashValue), case.counter)
def test_calculateHTId(self): distributedHT = LocalMemoryDHT(8, 10) for case in self.__cases: self.assertEqual(distributedHT._calculateHTId( case.hashValue), case.htId)