X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=blobdiff_plain;f=apt_p2p_Khashmir%2Fdb.py;h=d0433e04ea0fe3232d4d09cc5bc2043a135c5995;hp=bd777b60e78f65126859645a29152b49aeab80bd;hb=a5dd904be839e2b2896483724d6238b5a970b5de;hpb=e525e8eb8cc4536857146a1579f79d2d7793522d diff --git a/apt_p2p_Khashmir/db.py b/apt_p2p_Khashmir/db.py index bd777b6..d0433e0 100644 --- a/apt_p2p_Khashmir/db.py +++ b/apt_p2p_Khashmir/db.py @@ -103,7 +103,7 @@ class DB: c = self.conn.cursor() c.execute("DELETE FROM nodes WHERE id NOT NULL") for bucket in buckets: - for node in bucket.l: + for node in bucket.nodes: c.execute("INSERT INTO nodes VALUES (?, ?, ?)", (khash(node.id), node.host, node.port)) self.conn.commit() @@ -150,7 +150,7 @@ class DB: def keyStats(self): """Count the total number of keys and values in the database. - @rtype: (C{int), C{int}) + @rtype: (C{int}, C{int}) @return: the number of distinct keys and total values in the database """ c = self.conn.cursor() @@ -182,6 +182,7 @@ class TestDB(unittest.TestCase): def test_Value(self): self.store.storeValue(self.key, self.key) + self.failUnlessEqual(self.store.countValues(self.key), 1) val = self.store.retrieveValues(self.key) self.failUnlessEqual(len(val), 1) self.failUnlessEqual(val[0], self.key) @@ -208,7 +209,7 @@ class TestDB(unittest.TestCase): dummy2.port = 12345 class bl: def __init__(self): - self.l = [] + self.nodes = [] bl1 = bl() bl1.l.append(dummy()) bl2 = bl()