Skip to content

Commit

Permalink
fix: flaky test set up
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed Jan 4, 2024
1 parent cd7da49 commit 7d7979b
Showing 1 changed file with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,35 @@

from hrms.hr.utils import DuplicateDeclarationError

PAYROLL_PERIOD_NAME = "_Test Exemption Period"
PAYROLL_PERIOD_START = "2022-01-01"
PAYROLL_PERIOD_END = "2022-12-31"


class TestEmployeeTaxExemptionDeclaration(FrappeTestCase):
def setUp(self):
frappe.db.delete("Employee Tax Exemption Declaration")
frappe.db.delete("Salary Structure Assignment")
frappe.db.delete("Salary Slip")

make_employee("[email protected]", company="_Test Company")
make_employee("[email protected]", company="_Test Company")
create_payroll_period(company="_Test Company")

create_payroll_period(
company="_Test Company",
name=PAYROLL_PERIOD_NAME,
start_date=PAYROLL_PERIOD_START,
end_date=PAYROLL_PERIOD_END,
)
create_exemption_category()
frappe.db.delete("Employee Tax Exemption Declaration")
frappe.db.delete("Salary Structure Assignment")

def test_duplicate_category_in_declaration(self):
declaration = frappe.get_doc(
{
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id": "[email protected]"}, "name"),
"company": erpnext.get_default_company(),
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": erpnext.get_default_currency(),
"declarations": [
dict(
Expand All @@ -50,7 +62,7 @@ def test_duplicate_entry_for_payroll_period(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id": "[email protected]"}, "name"),
"company": erpnext.get_default_company(),
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": erpnext.get_default_currency(),
"declarations": [
dict(
Expand All @@ -72,7 +84,7 @@ def test_duplicate_entry_for_payroll_period(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id": "[email protected]"}, "name"),
"company": erpnext.get_default_company(),
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": erpnext.get_default_currency(),
"declarations": [
dict(
Expand All @@ -95,7 +107,7 @@ def test_exemption_amount(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": frappe.get_value("Employee", {"user_id": "[email protected]"}, "name"),
"company": erpnext.get_default_company(),
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": erpnext.get_default_currency(),
"declarations": [
dict(
Expand Down Expand Up @@ -127,7 +139,7 @@ def test_india_hra_exemption(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": "INR",
"monthly_house_rent": 50000,
"rented_in_metro_city": 1,
Expand Down Expand Up @@ -169,7 +181,7 @@ def test_india_hra_exemption_with_daily_payroll_frequency(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": "INR",
"monthly_house_rent": 170000,
"rented_in_metro_city": 1,
Expand Down Expand Up @@ -206,7 +218,7 @@ def test_india_hra_exemption_with_weekly_payroll_frequency(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": "INR",
"monthly_house_rent": 170000,
"rented_in_metro_city": 1,
Expand Down Expand Up @@ -243,7 +255,7 @@ def test_india_hra_exemption_with_fortnightly_payroll_frequency(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": "INR",
"monthly_house_rent": 170000,
"rented_in_metro_city": 1,
Expand Down Expand Up @@ -280,7 +292,7 @@ def test_india_hra_exemption_with_bimonthly_payroll_frequency(self):
"doctype": "Employee Tax Exemption Declaration",
"employee": employee,
"company": "_Test Company",
"payroll_period": "_Test Payroll Period",
"payroll_period": PAYROLL_PERIOD_NAME,
"currency": "INR",
"monthly_house_rent": 50000,
"rented_in_metro_city": 1,
Expand Down Expand Up @@ -321,8 +333,8 @@ def test_india_hra_exemption_with_multiple_salary_structure_assignments(self):
frappe.flags.country = "India"

employee = make_employee("[email protected]", company="_Test Company")
payroll_period = create_payroll_period(name="_Test Payroll Period", company="_Test Company")

payroll_period = frappe.get_doc("Payroll Period", PAYROLL_PERIOD_NAME)
create_tax_slab(
payroll_period,
allow_tax_exemption=True,
Expand Down Expand Up @@ -463,7 +475,12 @@ def setup_hra_exemption_prerequisites(frequency, employee=None):
from hrms.payroll.doctype.salary_slip.test_salary_slip import create_tax_slab
from hrms.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure

payroll_period = create_payroll_period(name="_Test Payroll Period", company="_Test Company")
payroll_period = create_payroll_period(
name=PAYROLL_PERIOD_NAME,
company="_Test Company",
start_date=PAYROLL_PERIOD_START,
end_date=PAYROLL_PERIOD_END,
)
if not employee:
employee = frappe.get_value("Employee", {"user_id": "[email protected]"}, "name")

Expand Down

0 comments on commit 7d7979b

Please sign in to comment.