def test_search_fast(test_db, test_vuln_data): table = test_db docs = db.list_all(table) assert len(docs) == 0 docs = db.store(test_db, test_vuln_data) assert len(docs) > 0 all_data = db.list_all(table) assert all_data search_list = [ d["details"]["package"] + "|" + d["details"]["max_affected_version"] for d in all_data ] res = db.pkg_bulk_search(test_db, search_list) assert len(res) > len(set(search_list)) assert res[0].to_dict()["package_issue"]
def test_index_search(test_db, test_vuln_data): # This slow test ensures that every data in the main database is indexed table = test_db docs = db.list_all(table) assert len(docs) == 0 docs = db.store(test_db, test_vuln_data) assert len(docs) > 0 all_data = db.list_all(table) assert all_data tmp_list = [] for d in all_data[:20]: tmp_list.append({ "name": d["details"]["package"], "version": d["details"]["max_affected_version"], }) res = db.bulk_index_search(tmp_list) assert len(res) for r in res: name_ver = r.split("|") fullres = db.index_search(name_ver[0], name_ver[1]) assert fullres
def store(self, data): """Store data in the database """ docs = dbLib.store(db, data) return docs
def test_gha_create(test_db, test_gha_data): docs = db.store(test_db, test_gha_data) assert len(docs) > len(test_gha_data)