def test_search(self): self.insert_test_events() results = global_search.search('awakens') self.assertTrue('After Mulder awakens from his coma, he realizes his duty to prevent alien colonization. ' in results[0].content) results = global_search.search('extraterrestrial') self.assertTrue('Carter explored themes of extraterrestrial involvement in ancient mass extinctions in this episode, the third in a trilogy.' in results[0].content)
def test_search(self): self.insert_test_events() results = global_search.search('awakens') self.assertTrue('After Mulder awakens from his coma, he realizes his duty to prevent alien colonization. ' in results[0].content) results = global_search.search('extraterrestrial') self.assertTrue('Carter explored themes of extraterrestrial involvement in ancient mass extinctions in this episode, the third in a trilogy.' in results[0].content)
def test_update_fields(self): self.insert_test_events() results = global_search.search('Every Month') self.assertEquals(len(results), 0) doctype = "Event" from frappe.custom.doctype.property_setter.property_setter import make_property_setter make_property_setter(doctype, "repeat_on", "in_global_search", 1, "Int") global_search.rebuild_for_doctype(doctype) results = global_search.search('Every Month') self.assertEquals(len(results), 3)
def test_update_fields(self): self.insert_test_events() results = global_search.search('Every Month') self.assertEqual(len(results), 0) doctype = "Event" from frappe.custom.doctype.property_setter.property_setter import make_property_setter make_property_setter(doctype, "repeat_on", "in_global_search", 1, "Int") global_search.rebuild_for_doctype(doctype) results = global_search.search('Every Month') self.assertEqual(len(results), 3)
def test_delete_doc(self): self.insert_test_events() event_name = frappe.get_all('Event')[0].name event = frappe.get_doc('Event', event_name) test_subject = event.subject results = global_search.search(test_subject) self.assertEqual(len(results), 1) frappe.delete_doc('Event', event_name) results = global_search.search(test_subject) self.assertEqual(len(results), 0)
def test_delete_doc(self): self.insert_test_events() event_name = frappe.get_all('Event')[0].name event = frappe.get_doc('Event', event_name) test_subject = event.subject results = global_search.search(test_subject) self.assertEquals(len(results), 1) frappe.delete_doc('Event', event_name) results = global_search.search(test_subject) self.assertEquals(len(results), 0)
def test_delete_doc(self): self.insert_test_events() event_name = frappe.get_all('Event')[0].name event = frappe.get_doc('Event', event_name) test_subject = event.subject results = global_search.search(test_subject) self.assertTrue(any(r["name"] == event_name for r in results), msg="Failed to search document by exact name") frappe.delete_doc('Event', event_name) global_search.sync_global_search() results = global_search.search(test_subject) self.assertTrue(all(r["name"] != event_name for r in results), msg="Deleted documents appearing in global search.")
def test_update_doc(self): self.insert_test_events() test_subject = 'testing global search' event = frappe.get_doc('Event', frappe.get_all('Event')[0].name) event.subject = test_subject event.save() frappe.db.commit() results = global_search.search('testing global search') self.assertTrue('testing global search' in results[0].content)
def test_update_doc(self): self.insert_test_events() test_subject = "testing global search" event = frappe.get_doc("Event", frappe.get_all("Event")[0].name) event.subject = test_subject event.save() frappe.db.commit() global_search.sync_global_search() results = global_search.search("testing global search") self.assertTrue("testing global search" in results[0].content)
def test_update_doc(self): self.insert_test_events() test_subject = 'testing global search' event = frappe.get_doc('Event', frappe.get_all('Event')[0].name) event.subject = test_subject event.save() frappe.db.commit() global_search.sync_global_search() results = global_search.search('testing global search') self.assertTrue('testing global search' in results[0].content)
def get_help_results_sections(text): out = [] settings = frappe.get_doc("Support Settings", "Support Settings") for api in settings.search_apis: results = [] if api.source_type == "API": response_json = get_response(api, text) topics_data = get_topics_data(api, response_json) results = prepare_api_results(api, topics_data) else: # Source type is Doctype doctype = api.source_doctype raw = search(text, 0, 20, doctype) results = prepare_doctype_results(api, raw) if results: # Add section out.append({"title": api.source_name, "results": results}) return out
def get_help_results_sections(text): out = [] settings = frappe.get_doc("Support Settings", "Support Settings") for api in settings.search_apis: results = [] if api.source_type == "API": response_json = get_response(api, text) topics_data = get_topics_data(api, response_json) results = prepare_api_results(api, topics_data) else: # Source type is Doctype doctype = api.source_doctype raw = search(text, 0, 20, doctype) results = prepare_doctype_results(api, raw) if results: # Add section out.append({ "title": api.source_name, "results": results }) return out