mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
chore: setup test data in class initialization
This commit is contained in:
@@ -87,12 +87,87 @@ class TestSalesInvoice(IntegrationTestCase):
|
|||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0))
|
cls.enterClassContext(cls.change_settings("Selling Settings", validate_selling_price=0))
|
||||||
|
cls.make_employees()
|
||||||
|
cls.make_sales_person()
|
||||||
unlink_payment_on_cancel_of_invoice()
|
unlink_payment_on_cancel_of_invoice()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(self):
|
def tearDownClass(self):
|
||||||
unlink_payment_on_cancel_of_invoice(0)
|
unlink_payment_on_cancel_of_invoice(0)
|
||||||
|
|
||||||
|
@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",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
for x in records:
|
||||||
|
if not frappe.db.exists("Employee", {"first_name": x.get("first_name")}):
|
||||||
|
frappe.get_doc(x).insert()
|
||||||
|
|
||||||
|
@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",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
for x in records:
|
||||||
|
if not frappe.db.exists("Sales Person", {"sales_person_name": x.get("sales_person_name")}):
|
||||||
|
frappe.get_doc(x).insert()
|
||||||
|
|
||||||
def test_sales_invoice_qty(self):
|
def test_sales_invoice_qty(self):
|
||||||
si = create_sales_invoice(qty=0, do_not_save=True)
|
si = create_sales_invoice(qty=0, do_not_save=True)
|
||||||
with self.assertRaises(InvalidQtyError):
|
with self.assertRaises(InvalidQtyError):
|
||||||
|
|||||||
Reference in New Issue
Block a user