Exemplo n.º 1
0
	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)
Exemplo n.º 2
0
	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)
Exemplo n.º 3
0
	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)
Exemplo n.º 4
0
	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)
Exemplo n.º 5
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.assertEqual(len(results), 1)

        frappe.delete_doc('Event', event_name)

        results = global_search.search(test_subject)
        self.assertEqual(len(results), 0)
Exemplo n.º 6
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)
Exemplo n.º 7
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.")
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
	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)
Exemplo n.º 10
0
	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)
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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