def test_update_vuln(self): vuln = MockVuln() kb.append('a', 'b', vuln) update_vuln = copy.deepcopy(vuln) update_vuln.set_name('a') update_uniq_id = update_vuln.get_uniq_id() kb.update(vuln, update_vuln) self.assertNotEqual(update_vuln, vuln) self.assertEqual(update_vuln, kb.get_by_uniq_id(update_uniq_id))
def test_update_info(self): info = MockInfo() kb.append('a', 'b', info) update_info = copy.deepcopy(info) update_info.set_name('a') update_uniq_id = update_info.get_uniq_id() kb.update(info, update_info) self.assertNotEqual(update_info, info) self.assertEqual(update_info, kb.get_by_uniq_id(update_uniq_id))
def test_get_by_uniq_id_duplicated_ignores_second(self): """ TODO: Analyze this case, i1 and i2 have both the same ID because they have all the same information (this is very very uncommon in a real w3af run). Note that in the get_by_uniq_id call i2 is not returned. """ i1 = MockInfo() i2 = MockInfo() kb.append('a', 'b', i1) kb.append('a', 'b', i2) i1_copy = kb.get_by_uniq_id(i1.get_uniq_id()) self.assertEqual(i1_copy, i1)
def test_get_by_uniq_id_not_exists(self): self.assertIs(kb.get_by_uniq_id(hash('foo')), None)
def test_get_by_uniq_id(self): i1 = MockInfo() kb.append('a', 'b', i1) i1_copy = kb.get_by_uniq_id(i1.get_uniq_id()) self.assertEqual(i1_copy, i1)