Exemple #1
0
 def test_repr(self):
     c1 = contact.Contact(self.ipv4, self.port1, self.guid1)
     cr = repr(c1)
     self.assertEqual(
         cr,
         'Contact({0}, {1}, {2})'.format(self.ipv4, self.port1, self.guid1)
     )
Exemple #2
0
 def setUpClass(cls):
     cls.range_min = 0
     cls.range_max = 2**constants.BIT_NODE_ID_LEN
     cls.own_num_guid = 1
     cls.own_guid = util.num_to_guid(cls.own_num_guid)
     cls.bad_guid = 'f' * (constants.HEX_NODE_ID_LEN + 1)
     cls.bad_contact = contact.Contact('123.45.67.89', 12345, cls.bad_guid)
Exemple #3
0
 def test_add_self_contact(self):
     self_contact = contact.Contact('123.45.67.89', 12345, self.own_guid)
     self.rt.add_contact(self_contact)
     self.assertIsNone(self.rt.get_contact(self.own_guid))
     self.assertEqual(len(self.rt), 1)
     self.assertEqual(list(self.rt[0]), [])
Exemple #4
0
 def _make_contact_from_num(i):
     return contact.Contact('123.45.67.89', 12345, util.num_to_guid(i))
Exemple #5
0
 def test_uneq(self):
     c1 = contact.Contact(self.ipv4, self.port1, self.guid1)
     c2 = contact.Contact(self.ipv4, self.port1, self.guid2)
     self.assertNotEqual(c1, c2)
Exemple #6
0
 def test_eq_hash(self):
     c1 = contact.Contact(self.ipv4, self.port1, self.guid1)
     c2 = contact.Contact(self.ipv6, self.port2, self.guid1)
     self.assertIsNot(c1, c2)
     self.assertEqual(c1, c2)
     self.assertEqual(hash(c1), hash(c2))
Exemple #7
0
 def _test_init_scenario(self, ip, port, guid):
     contact1 = contact.Contact(ip, port, guid)
     self.assertEqual(contact1.ip, ip)
     self.assertEqual(contact1.port, port)
     self.assertEqual(contact1.guid, guid)