|
@@ -2,13 +2,14 @@ |
|
|
# License: MIT. See LICENSE |
|
|
# License: MIT. See LICENSE |
|
|
|
|
|
|
|
|
import unittest |
|
|
import unittest |
|
|
|
|
|
|
|
|
import frappe |
|
|
import frappe |
|
|
|
|
|
|
|
|
from frappe.utils import global_search |
|
|
|
|
|
from frappe.test_runner import make_test_objects |
|
|
|
|
|
|
|
|
from frappe.custom.doctype.property_setter.property_setter import make_property_setter |
|
|
from frappe.desk.page.setup_wizard.install_fixtures import update_global_search_doctypes |
|
|
from frappe.desk.page.setup_wizard.install_fixtures import update_global_search_doctypes |
|
|
|
|
|
from frappe.utils import global_search, now_datetime |
|
|
|
|
|
from frappe.test_runner import make_test_objects |
|
|
|
|
|
|
|
|
import frappe.utils |
|
|
|
|
|
|
|
|
|
|
|
class TestGlobalSearch(unittest.TestCase): |
|
|
class TestGlobalSearch(unittest.TestCase): |
|
|
def setUp(self): |
|
|
def setUp(self): |
|
@@ -17,7 +18,6 @@ class TestGlobalSearch(unittest.TestCase): |
|
|
self.assertTrue('__global_search' in frappe.db.get_tables()) |
|
|
self.assertTrue('__global_search' in frappe.db.get_tables()) |
|
|
doctype = "Event" |
|
|
doctype = "Event" |
|
|
global_search.reset() |
|
|
global_search.reset() |
|
|
from frappe.custom.doctype.property_setter.property_setter import make_property_setter |
|
|
|
|
|
make_property_setter(doctype, "subject", "in_global_search", 1, "Int") |
|
|
make_property_setter(doctype, "subject", "in_global_search", 1, "Int") |
|
|
make_property_setter(doctype, "event_type", "in_global_search", 1, "Int") |
|
|
make_property_setter(doctype, "event_type", "in_global_search", 1, "Int") |
|
|
make_property_setter(doctype, "roles", "in_global_search", 1, "Int") |
|
|
make_property_setter(doctype, "roles", "in_global_search", 1, "Int") |
|
@@ -42,12 +42,11 @@ class TestGlobalSearch(unittest.TestCase): |
|
|
doctype='Event', |
|
|
doctype='Event', |
|
|
subject=text, |
|
|
subject=text, |
|
|
repeat_on='Monthly', |
|
|
repeat_on='Monthly', |
|
|
starts_on=frappe.utils.now_datetime())).insert() |
|
|
|
|
|
|
|
|
starts_on=now_datetime())).insert() |
|
|
|
|
|
|
|
|
global_search.sync_global_search() |
|
|
global_search.sync_global_search() |
|
|
frappe.db.commit() |
|
|
frappe.db.commit() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_search(self): |
|
|
def test_search(self): |
|
|
self.insert_test_events() |
|
|
self.insert_test_events() |
|
|
results = global_search.search('awakens') |
|
|
results = global_search.search('awakens') |
|
@@ -75,7 +74,6 @@ class TestGlobalSearch(unittest.TestCase): |
|
|
results = global_search.search('Monthly') |
|
|
results = global_search.search('Monthly') |
|
|
self.assertEqual(len(results), 0) |
|
|
self.assertEqual(len(results), 0) |
|
|
doctype = "Event" |
|
|
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") |
|
|
make_property_setter(doctype, "repeat_on", "in_global_search", 1, "Int") |
|
|
global_search.rebuild_for_doctype(doctype) |
|
|
global_search.rebuild_for_doctype(doctype) |
|
|
results = global_search.search('Monthly') |
|
|
results = global_search.search('Monthly') |
|
@@ -111,7 +109,7 @@ class TestGlobalSearch(unittest.TestCase): |
|
|
doc = frappe.get_doc({ |
|
|
doc = frappe.get_doc({ |
|
|
'doctype':'Event', |
|
|
'doctype':'Event', |
|
|
'subject': text, |
|
|
'subject': text, |
|
|
'starts_on': frappe.utils.now_datetime() |
|
|
|
|
|
|
|
|
'starts_on': now_datetime() |
|
|
}) |
|
|
}) |
|
|
doc.insert() |
|
|
doc.insert() |
|
|
|
|
|
|
|
@@ -172,7 +170,7 @@ class TestGlobalSearch(unittest.TestCase): |
|
|
doc = frappe.get_doc({ |
|
|
doc = frappe.get_doc({ |
|
|
'doctype':'Event', |
|
|
'doctype':'Event', |
|
|
'subject': 'Lorem Ipsum', |
|
|
'subject': 'Lorem Ipsum', |
|
|
'starts_on': frappe.utils.now_datetime(), |
|
|
|
|
|
|
|
|
'starts_on': now_datetime(), |
|
|
'description': case["data"] |
|
|
'description': case["data"] |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|