mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-12 19:35:09 +00:00
Merge pull request #47309 from ruthra-kumar/fix_broken_local_test_suite
chore: first step in the journey to reliable test suite
This commit is contained in:
@@ -3,18 +3,22 @@
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import now_datetime, nowdate
|
||||
|
||||
from erpnext.accounts.doctype.budget.budget import BudgetError, get_actual_expense
|
||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||
|
||||
EXTRA_TEST_RECORD_DEPENDENCIES = ["Monthly Distribution"]
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestBudget(IntegrationTestCase):
|
||||
class TestBudget(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_monthly_distribution()
|
||||
cls.make_projects()
|
||||
|
||||
def test_monthly_budget_crossed_ignore(self):
|
||||
set_total_expense_zero(nowdate(), "cost_center")
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
[{
|
||||
"doctype": "Monthly Distribution",
|
||||
"distribution_id": "_Test Distribution",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"percentages": [
|
||||
{
|
||||
"month": "January",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "February",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "March",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "April",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "May",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "June",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "July",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "August",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "September",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "October",
|
||||
"percentage_allocation": "8"
|
||||
}, {
|
||||
"month": "November",
|
||||
"percentage_allocation": "10"
|
||||
}, {
|
||||
"month": "December",
|
||||
"percentage_allocation": "10"
|
||||
}
|
||||
]
|
||||
}]
|
||||
@@ -55,20 +55,6 @@
|
||||
],
|
||||
"plc_conversion_rate": 1.0,
|
||||
"price_list_currency": "INR",
|
||||
"sales_team": [
|
||||
{
|
||||
"allocated_percentage": 65.5,
|
||||
"doctype": "Sales Team",
|
||||
"parentfield": "sales_team",
|
||||
"sales_person": "_Test Sales Person 1"
|
||||
},
|
||||
{
|
||||
"allocated_percentage": 34.5,
|
||||
"doctype": "Sales Team",
|
||||
"parentfield": "sales_team",
|
||||
"sales_person": "_Test Sales Person 2"
|
||||
}
|
||||
],
|
||||
"selling_price_list": "_Test Price List",
|
||||
"territory": "_Test Territory"
|
||||
},
|
||||
|
||||
@@ -48,6 +48,7 @@ from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import
|
||||
)
|
||||
from erpnext.stock.get_item_details import get_item_tax_map
|
||||
from erpnext.stock.utils import get_incoming_rate, get_stock_balance
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class UnitTestSalesInvoice(UnitTestCase):
|
||||
@@ -59,7 +60,7 @@ class UnitTestSalesInvoice(UnitTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestSalesInvoice(IntegrationTestCase):
|
||||
class TestSalesInvoice(ERPNextTestSuite):
|
||||
def setUp(self):
|
||||
from erpnext.stock.doctype.stock_ledger_entry.test_stock_ledger_entry import create_items
|
||||
|
||||
@@ -87,6 +88,8 @@ class TestSalesInvoice(IntegrationTestCase):
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0))
|
||||
cls.make_employees()
|
||||
cls.make_sales_person()
|
||||
unlink_payment_on_cancel_of_invoice()
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -8,18 +8,26 @@ from frappe.custom.doctype.property_setter.property_setter import make_property_
|
||||
from frappe.tests import IntegrationTestCase
|
||||
|
||||
from erpnext.controllers import queries
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
def add_default_params(func, doctype):
|
||||
return partial(func, doctype=doctype, txt="", searchfield="name", start=0, page_len=20, filters=None)
|
||||
|
||||
|
||||
EXTRA_TEST_RECORD_DEPENDENCIES = ["Employee", "Lead", "Item", "BOM", "Project", "Account"]
|
||||
EXTRA_TEST_RECORD_DEPENDENCIES = ["Item", "BOM", "Account"]
|
||||
|
||||
|
||||
class TestQueries(IntegrationTestCase):
|
||||
class TestQueries(ERPNextTestSuite):
|
||||
# All tests are based on self.globalTestRecords[doctype]
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_employees()
|
||||
cls.make_leads()
|
||||
cls.make_projects()
|
||||
|
||||
def assert_nested_in(self, item, container):
|
||||
self.assertIn(item, [vals for tuples in container for vals in tuples])
|
||||
|
||||
@@ -105,7 +113,7 @@ class TestQueries(IntegrationTestCase):
|
||||
{
|
||||
"user": user.name,
|
||||
"doctype": "Employee",
|
||||
"docname": "_T-Employee-00001",
|
||||
"docname": self.employees[0].name,
|
||||
"is_default": 1,
|
||||
"apply_to_all_doctypes": 1,
|
||||
"applicable_doctypes": [],
|
||||
|
||||
@@ -8,17 +8,23 @@ from frappe.utils import random_string, today
|
||||
|
||||
from erpnext.crm.doctype.lead.lead import make_opportunity
|
||||
from erpnext.crm.utils import get_linked_prospect
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestLead(IntegrationTestCase):
|
||||
class TestLead(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_leads()
|
||||
|
||||
def test_make_customer(self):
|
||||
from erpnext.crm.doctype.lead.lead import make_customer
|
||||
|
||||
frappe.delete_doc_if_exists("Customer", "_Test Lead")
|
||||
|
||||
customer = make_customer("_T-Lead-00001")
|
||||
customer = make_customer(self.leads[0].name)
|
||||
self.assertEqual(customer.doctype, "Customer")
|
||||
self.assertEqual(customer.lead_name, "_T-Lead-00001")
|
||||
self.assertEqual(customer.lead_name, self.leads[0].name)
|
||||
|
||||
customer.company = "_Test Company"
|
||||
customer.customer_group = "_Test Customer Group"
|
||||
@@ -42,9 +48,9 @@ class TestLead(IntegrationTestCase):
|
||||
def test_make_customer_from_organization(self):
|
||||
from erpnext.crm.doctype.lead.lead import make_customer
|
||||
|
||||
customer = make_customer("_T-Lead-00002")
|
||||
customer = make_customer(self.leads[1].name)
|
||||
self.assertEqual(customer.doctype, "Customer")
|
||||
self.assertEqual(customer.lead_name, "_T-Lead-00002")
|
||||
self.assertEqual(customer.lead_name, self.leads[1].name)
|
||||
|
||||
customer.company = "_Test Company"
|
||||
customer.customer_group = "_Test Customer Group"
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
[
|
||||
{
|
||||
"doctype": "Lead",
|
||||
"email_id": "test_lead@example.com",
|
||||
"lead_name": "_Test Lead",
|
||||
"status": "Open",
|
||||
"territory": "_Test Territory"
|
||||
},
|
||||
{
|
||||
"doctype": "Lead",
|
||||
"email_id": "test_lead1@example.com",
|
||||
"lead_name": "_Test Lead 1",
|
||||
"status": "Open"
|
||||
},
|
||||
{
|
||||
"doctype": "Lead",
|
||||
"email_id": "test_lead2@example.com",
|
||||
"lead_name": "_Test Lead 2",
|
||||
"status": "Lead"
|
||||
},
|
||||
{
|
||||
"doctype": "Lead",
|
||||
"email_id": "test_lead3@example.com",
|
||||
"lead_name": "_Test Lead 3",
|
||||
"status": "Converted"
|
||||
},
|
||||
{
|
||||
"doctype": "Lead",
|
||||
"email_id": "test_lead4@example.com",
|
||||
"lead_name": "_Test Lead 4",
|
||||
"company_name": "_Test Lead 4",
|
||||
"status": "Open"
|
||||
}
|
||||
]
|
||||
@@ -10,9 +10,40 @@ from erpnext.crm.doctype.lead.lead import make_customer
|
||||
from erpnext.crm.doctype.lead.test_lead import make_lead
|
||||
from erpnext.crm.doctype.opportunity.opportunity import make_quotation
|
||||
from erpnext.crm.utils import get_linked_communication_list
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestOpportunity(IntegrationTestCase):
|
||||
class TestOpportunity(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
# Only first lead is required
|
||||
# TODO: dynamically generate limited test records
|
||||
cls.make_leads()
|
||||
cls.make_opportunities()
|
||||
|
||||
@classmethod
|
||||
def make_opportunities(cls):
|
||||
records = [
|
||||
{
|
||||
"doctype": "Opportunity",
|
||||
"name": "_Test Opportunity 1",
|
||||
"opportunity_from": "Lead",
|
||||
"enquiry_type": "Sales",
|
||||
"party_name": cls.leads[0].name,
|
||||
"transaction_date": "2013-12-12",
|
||||
"items": [
|
||||
{"item_name": "Test Item", "description": "Some description", "qty": 5, "rate": 100}
|
||||
],
|
||||
}
|
||||
]
|
||||
cls.opportunities = []
|
||||
for x in records:
|
||||
if not frappe.db.exists("Opportunity", {"name": x.get("name")}):
|
||||
cls.opportunities.append(frappe.get_doc(x).insert())
|
||||
else:
|
||||
cls.opportunities.append(frappe.get_doc("Opportunity", {"party_name": x.get("party_name")}))
|
||||
|
||||
def test_opportunity_status(self):
|
||||
doc = make_opportunity(with_items=0)
|
||||
quotation = make_quotation(doc.name)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
[
|
||||
{
|
||||
"doctype": "Opportunity",
|
||||
"name": "_Test Opportunity 1",
|
||||
"opportunity_from": "Lead",
|
||||
"enquiry_type": "Sales",
|
||||
"party_name": "_T-Lead-00001",
|
||||
"transaction_date": "2013-12-12",
|
||||
"items": [{
|
||||
"item_name": "Test Item",
|
||||
"description": "Some description",
|
||||
"qty": 5,
|
||||
"rate": 100
|
||||
}]
|
||||
}
|
||||
]
|
||||
@@ -16,6 +16,30 @@ from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_i
|
||||
|
||||
|
||||
class TestMaintenanceSchedule(IntegrationTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_sales_person()
|
||||
|
||||
@classmethod
|
||||
def make_sales_person(cls):
|
||||
records = [
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person",
|
||||
},
|
||||
]
|
||||
cls.sales_person = []
|
||||
for x in records:
|
||||
if not frappe.db.exists("Sales Person", {"sales_person_name": x.get("sales_person_name")}):
|
||||
cls.sales_person.append(frappe.get_doc(x).insert())
|
||||
else:
|
||||
cls.sales_person.append(
|
||||
frappe.get_doc("Sales Person", {"sales_person_name": x.get("sales_person_name")})
|
||||
)
|
||||
|
||||
def test_events_should_be_created_and_deleted(self):
|
||||
ms = make_maintenance_schedule()
|
||||
ms.generate_schedule()
|
||||
@@ -136,7 +160,7 @@ class TestMaintenanceSchedule(IntegrationTestCase):
|
||||
self.assertFalse(ms.validate_items_table_change())
|
||||
# After Save
|
||||
ms.items[0].serial_no = "TEST001"
|
||||
ms.items[0].sales_person = "_Test Sales Person"
|
||||
ms.items[0].sales_person = self.sales_person[0].name
|
||||
ms.items[0].no_of_visits = 2
|
||||
self.assertTrue(ms.validate_items_table_change())
|
||||
ms.save()
|
||||
|
||||
@@ -6,16 +6,23 @@ import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
|
||||
from erpnext.projects.doctype.activity_cost.activity_cost import DuplicationError
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestActivityCost(IntegrationTestCase):
|
||||
class TestActivityCost(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
# TODO: only 1 employee is required
|
||||
cls.make_employees()
|
||||
|
||||
def test_duplication(self):
|
||||
frappe.db.sql("delete from `tabActivity Cost`")
|
||||
activity_cost1 = frappe.new_doc("Activity Cost")
|
||||
activity_cost1.update(
|
||||
{
|
||||
"employee": "_T-Employee-00001",
|
||||
"employee_name": "_Test Employee",
|
||||
"employee": self.employees[0].name,
|
||||
"employee_name": self.employees[0].first_name,
|
||||
"activity_type": "_Test Activity Type 1",
|
||||
"billing_rate": 100,
|
||||
"costing_rate": 50,
|
||||
|
||||
@@ -9,6 +9,7 @@ from erpnext.projects.doctype.project_template.test_project_template import make
|
||||
from erpnext.projects.doctype.task.test_task import create_task
|
||||
from erpnext.selling.doctype.sales_order.sales_order import make_project as make_project_from_so
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
IGNORE_TEST_RECORD_DEPENDENCIES = ["Sales Order"]
|
||||
|
||||
@@ -22,7 +23,12 @@ class UnitTestProject(UnitTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestProject(IntegrationTestCase):
|
||||
class TestProject(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_projects()
|
||||
|
||||
def test_project_with_template_having_no_parent_and_depend_tasks(self):
|
||||
project_name = "Test Project with Template - No Parent and Dependend Tasks"
|
||||
frappe.db.sql(""" delete from tabTask where project = %s """, project_name)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[
|
||||
{
|
||||
"company": "_Test Company",
|
||||
"project_name": "_Test Project",
|
||||
"status": "Open"
|
||||
}
|
||||
]
|
||||
@@ -7,9 +7,15 @@ from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import add_days, getdate, nowdate
|
||||
|
||||
from erpnext.projects.doctype.task.task import CircularReferenceError
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestTask(IntegrationTestCase):
|
||||
class TestTask(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_projects()
|
||||
|
||||
def test_circular_reference(self):
|
||||
task1 = create_task("_Test Task 1", add_days(nowdate(), -15), add_days(nowdate(), -10))
|
||||
task2 = create_task("_Test Task 2", add_days(nowdate(), 11), add_days(nowdate(), 15), task1.name)
|
||||
|
||||
@@ -10,9 +10,15 @@ from frappe.utils import add_to_date, now_datetime, nowdate
|
||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||
from erpnext.projects.doctype.timesheet.timesheet import OverlapError, make_sales_invoice
|
||||
from erpnext.setup.doctype.employee.test_employee import make_employee
|
||||
from erpnext.tests.utils import ERPNextTestSuite
|
||||
|
||||
|
||||
class TestTimesheet(IntegrationTestCase):
|
||||
class TestTimesheet(ERPNextTestSuite):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.make_projects()
|
||||
|
||||
def setUp(self):
|
||||
frappe.db.delete("Timesheet")
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
@@ -1,23 +0,0 @@
|
||||
[
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00001",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person"
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00002",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person 1"
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00003",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person 2"
|
||||
}
|
||||
]
|
||||
@@ -1,8 +0,0 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
EXTRA_TEST_RECORD_DEPENDENCIES = ["Employee"]
|
||||
|
||||
import frappe
|
||||
|
||||
IGNORE_TEST_RECORD_DEPENDENCIES = ["Item Group"]
|
||||
@@ -5,6 +5,7 @@ from typing import Any, NewType
|
||||
|
||||
import frappe
|
||||
from frappe.core.doctype.report.report import get_report_module_dotted_path
|
||||
from frappe.tests import IntegrationTestCase
|
||||
|
||||
ReportFilters = dict[str, Any]
|
||||
ReportName = NewType("ReportName", str)
|
||||
@@ -114,3 +115,188 @@ def if_lending_app_not_installed(function):
|
||||
return
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
class ERPNextTestSuite(IntegrationTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
|
||||
@classmethod
|
||||
def make_monthly_distribution(cls):
|
||||
records = [
|
||||
{
|
||||
"doctype": "Monthly Distribution",
|
||||
"distribution_id": "_Test Distribution",
|
||||
"fiscal_year": "_Test Fiscal Year 2013",
|
||||
"percentages": [
|
||||
{"month": "January", "percentage_allocation": "8"},
|
||||
{"month": "February", "percentage_allocation": "8"},
|
||||
{"month": "March", "percentage_allocation": "8"},
|
||||
{"month": "April", "percentage_allocation": "8"},
|
||||
{"month": "May", "percentage_allocation": "8"},
|
||||
{"month": "June", "percentage_allocation": "8"},
|
||||
{"month": "July", "percentage_allocation": "8"},
|
||||
{"month": "August", "percentage_allocation": "8"},
|
||||
{"month": "September", "percentage_allocation": "8"},
|
||||
{"month": "October", "percentage_allocation": "8"},
|
||||
{"month": "November", "percentage_allocation": "10"},
|
||||
{"month": "December", "percentage_allocation": "10"},
|
||||
],
|
||||
}
|
||||
]
|
||||
cls.monthly_distribution = []
|
||||
for x in records:
|
||||
if not frappe.db.exists("Monthly Distribution", {"distribution_id": x.get("distribution_id")}):
|
||||
cls.monthly_distribution.append(frappe.get_doc(x).insert())
|
||||
else:
|
||||
cls.monthly_distribution.append(
|
||||
frappe.get_doc("Monthly Distribution", {"distribution_id": x.get("distribution_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")}))
|
||||
|
||||
@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_sales_person(cls):
|
||||
records = [
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00001",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person",
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00002",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person 1",
|
||||
},
|
||||
{
|
||||
"doctype": "Sales Person",
|
||||
"employee": "_T-Employee-00003",
|
||||
"is_group": 0,
|
||||
"parent_sales_person": "Sales Team",
|
||||
"sales_person_name": "_Test Sales Person 2",
|
||||
},
|
||||
]
|
||||
cls.sales_person = []
|
||||
for x in records:
|
||||
if not frappe.db.exists("Sales Person", {"sales_person_name": x.get("sales_person_name")}):
|
||||
cls.sales_person.append(frappe.get_doc(x).insert())
|
||||
else:
|
||||
cls.sales_person.append(
|
||||
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