def toggleBookmark(self, cell, path, model): """Toggle bookmark.""" model[path][1] = not model[path][1] historyItem = HistoryItem() historyItem.load(model[path][0]) historyItem.toggleMark(True) return
def test_find(self): find_id = random.randint(1, 499) url = url_object('http://w3af.org/a/b/foobar.php?foo=123') tag_value = createRandAlNum(10) for i in xrange(0, 500): fr = FuzzReq(url, dc={'a': ['1']}) code = 200 if i == find_id: code = 302 res = httpResponse(code, '<html>',{'Content-Type':'text/html'}, url, url) h1 = HistoryItem() h1.request = fr res.setId(i) h1.response = res if i == find_id: h1.toggleMark() h1.updateTag(tag_value) h1.save() h2 = HistoryItem() self.assertEqual(len(h2.find([('tag', "%"+tag_value+"%", 'like')])), 1) self.assertEqual(len(h2.find([('code', 302, '=')])), 1) self.assertEqual(len(h2.find([('mark', 1, '=')])), 1) self.assertEqual(len(h2.find([('has_qs', 1, '=')])), 500) self.assertEqual(len(h2.find([('has_qs', 1, '=')], resultLimit=10)), 10) results = h2.find([('has_qs', 1, '=')], resultLimit=1, orderData=[('id','desc')]) self.assertEqual(results[0].id, 499) search_data = [] search_data.append(('id', find_id + 1, "<")) search_data.append(('id', find_id - 1, ">")) self.assertEqual(len(h2.find(search_data)), 1)
def test_mark(self): mark_id = random.randint(1, 499) url = url_object('http://w3af.org/a/b/c.php') for i in xrange(0, 500): fr = FuzzReq(url, dc={'a': ['1']}) res = httpResponse(200, '<html>',{'Content-Type':'text/html'}, url, url) h1 = HistoryItem() h1.request = fr res.setId(i) h1.response = res if i == mark_id: h1.toggleMark() h1.save() h2 = HistoryItem() h2.load(mark_id) self.assertTrue(h2.mark)