mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 19:29:10 +00:00
refactor(test): Queries test suite to use ERPNextTestSuite
This commit is contained in:
@@ -8,6 +8,7 @@ from frappe.custom.doctype.property_setter.property_setter import make_property_
|
|||||||
from frappe.tests import IntegrationTestCase
|
from frappe.tests import IntegrationTestCase
|
||||||
|
|
||||||
from erpnext.controllers import queries
|
from erpnext.controllers import queries
|
||||||
|
from erpnext.tests.utils import ERPNextTestSuite
|
||||||
|
|
||||||
|
|
||||||
def add_default_params(func, doctype):
|
def add_default_params(func, doctype):
|
||||||
@@ -17,7 +18,7 @@ def add_default_params(func, doctype):
|
|||||||
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "BOM", "Account"]
|
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "BOM", "Account"]
|
||||||
|
|
||||||
|
|
||||||
class TestQueries(IntegrationTestCase):
|
class TestQueries(ERPNextTestSuite):
|
||||||
# All tests are based on self.globalTestRecords[doctype]
|
# All tests are based on self.globalTestRecords[doctype]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -27,119 +28,6 @@ class TestQueries(IntegrationTestCase):
|
|||||||
cls.make_leads()
|
cls.make_leads()
|
||||||
cls.make_projects()
|
cls.make_projects()
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def make_employees(cls):
|
|
||||||
records = [
|
|
||||||
{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"date_of_birth": "1980-01-01",
|
|
||||||
"date_of_joining": "2010-01-01",
|
|
||||||
"department": "_Test Department - _TC",
|
|
||||||
"doctype": "Employee",
|
|
||||||
"first_name": "_Test Employee",
|
|
||||||
"gender": "Female",
|
|
||||||
"naming_series": "_T-Employee-",
|
|
||||||
"status": "Active",
|
|
||||||
"user_id": "test@example.com",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"date_of_birth": "1980-01-01",
|
|
||||||
"date_of_joining": "2010-01-01",
|
|
||||||
"department": "_Test Department 1 - _TC",
|
|
||||||
"doctype": "Employee",
|
|
||||||
"first_name": "_Test Employee 1",
|
|
||||||
"gender": "Male",
|
|
||||||
"naming_series": "_T-Employee-",
|
|
||||||
"status": "Active",
|
|
||||||
"user_id": "test1@example.com",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"date_of_birth": "1980-01-01",
|
|
||||||
"date_of_joining": "2010-01-01",
|
|
||||||
"department": "_Test Department 1 - _TC",
|
|
||||||
"doctype": "Employee",
|
|
||||||
"first_name": "_Test Employee 2",
|
|
||||||
"gender": "Male",
|
|
||||||
"naming_series": "_T-Employee-",
|
|
||||||
"status": "Active",
|
|
||||||
"user_id": "test2@example.com",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
cls.employees = []
|
|
||||||
for x in records:
|
|
||||||
if not frappe.db.exists("Employee", {"first_name": x.get("first_name")}):
|
|
||||||
cls.employees.append(frappe.get_doc(x).insert())
|
|
||||||
else:
|
|
||||||
cls.employees.append(frappe.get_doc("Employee", {"first_name": x.get("first_name")}))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def make_leads(cls):
|
|
||||||
records = [
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead@example.com",
|
|
||||||
"lead_name": "_Test Lead",
|
|
||||||
"status": "Open",
|
|
||||||
"territory": "_Test Territory",
|
|
||||||
"naming_series": "_T-Lead-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead1@example.com",
|
|
||||||
"lead_name": "_Test Lead 1",
|
|
||||||
"status": "Open",
|
|
||||||
"naming_series": "_T-Lead-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead2@example.com",
|
|
||||||
"lead_name": "_Test Lead 2",
|
|
||||||
"status": "Lead",
|
|
||||||
"naming_series": "_T-Lead-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead3@example.com",
|
|
||||||
"lead_name": "_Test Lead 3",
|
|
||||||
"status": "Converted",
|
|
||||||
"naming_series": "_T-Lead-",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead4@example.com",
|
|
||||||
"lead_name": "_Test Lead 4",
|
|
||||||
"company_name": "_Test Lead 4",
|
|
||||||
"status": "Open",
|
|
||||||
"naming_series": "_T-Lead-",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
cls.leads = []
|
|
||||||
for x in records:
|
|
||||||
if not frappe.db.exists("Lead", {"email_id": x.get("email_id")}):
|
|
||||||
cls.leads.append(frappe.get_doc(x).insert())
|
|
||||||
else:
|
|
||||||
cls.leads.append(frappe.get_doc("Lead", {"email_id": x.get("email_id")}))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def make_projects(cls):
|
|
||||||
records = [
|
|
||||||
{
|
|
||||||
"doctype": "Project",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"project_name": "_Test Project",
|
|
||||||
"status": "Open",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
cls.projects = []
|
|
||||||
for x in records:
|
|
||||||
if not frappe.db.exists("Project", {"project_name": x.get("project_name")}):
|
|
||||||
cls.projects.append(frappe.get_doc(x).insert())
|
|
||||||
else:
|
|
||||||
cls.projects.append(frappe.get_doc("Project", {"project_name": x.get("project_name")}))
|
|
||||||
|
|
||||||
def assert_nested_in(self, item, container):
|
def assert_nested_in(self, item, container):
|
||||||
self.assertIn(item, [vals for tuples in container for vals in tuples])
|
self.assertIn(item, [vals for tuples in container for vals in tuples])
|
||||||
|
|
||||||
|
|||||||
@@ -252,3 +252,51 @@ class ERPNextTestSuite(IntegrationTestCase):
|
|||||||
cls.sales_person.append(
|
cls.sales_person.append(
|
||||||
frappe.get_doc("Sales Person", {"sales_person_name": x.get("sales_person_name")})
|
frappe.get_doc("Sales Person", {"sales_person_name": x.get("sales_person_name")})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def make_leads(cls):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead@example.com",
|
||||||
|
"lead_name": "_Test Lead",
|
||||||
|
"status": "Open",
|
||||||
|
"territory": "_Test Territory",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead1@example.com",
|
||||||
|
"lead_name": "_Test Lead 1",
|
||||||
|
"status": "Open",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead2@example.com",
|
||||||
|
"lead_name": "_Test Lead 2",
|
||||||
|
"status": "Lead",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead3@example.com",
|
||||||
|
"lead_name": "_Test Lead 3",
|
||||||
|
"status": "Converted",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead4@example.com",
|
||||||
|
"lead_name": "_Test Lead 4",
|
||||||
|
"company_name": "_Test Lead 4",
|
||||||
|
"status": "Open",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
cls.leads = []
|
||||||
|
for x in records:
|
||||||
|
if not frappe.db.exists("Lead", {"email_id": x.get("email_id")}):
|
||||||
|
cls.leads.append(frappe.get_doc(x).insert())
|
||||||
|
else:
|
||||||
|
cls.leads.append(frappe.get_doc("Lead", {"email_id": x.get("email_id")}))
|
||||||
|
|||||||
Reference in New Issue
Block a user