fix: Program Enrollment tests (#29592)

This commit is contained in:
Rucha Mahabal 2022-02-02 17:30:29 +05:30 committed by GitHub
parent bf3caab63c
commit da7494c208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import frappe
from frappe import _, msgprint from frappe import _, msgprint
from frappe.desk.reportview import get_match_cond from frappe.desk.reportview import get_match_cond
from frappe.model.document import Document from frappe.model.document import Document
from frappe.query_builder.functions import Min
from frappe.utils import comma_and, get_link_to_form, getdate from frappe.utils import comma_and, get_link_to_form, getdate
@ -60,8 +61,15 @@ class ProgramEnrollment(Document):
frappe.throw(_("Student is already enrolled.")) frappe.throw(_("Student is already enrolled."))
def update_student_joining_date(self): def update_student_joining_date(self):
date = frappe.db.sql("select min(enrollment_date) from `tabProgram Enrollment` where student= %s", self.student) table = frappe.qb.DocType('Program Enrollment')
frappe.db.set_value("Student", self.student, "joining_date", date) date = (
frappe.qb.from_(table)
.select(Min(table.enrollment_date).as_('enrollment_date'))
.where(table.student == self.student)
).run(as_dict=True)
if date:
frappe.db.set_value("Student", self.student, "joining_date", date[0].enrollment_date)
def make_fee_records(self): def make_fee_records(self):
from erpnext.education.api import get_fee_components from erpnext.education.api import get_fee_components

View File

@ -207,8 +207,8 @@ class TestEmployeeReminders(unittest.TestCase):
# teardown: enable emp 2 # teardown: enable emp 2
frappe.db.set_value('Employee', self.test_employee_2.name, { frappe.db.set_value('Employee', self.test_employee_2.name, {
'status': 'Left', 'status': 'Active',
'holiday_list': self.holiday_list_2 'holiday_list': self.holiday_list_2.name
}) })
def test_advance_holiday_reminders_weekly(self): def test_advance_holiday_reminders_weekly(self):
@ -232,8 +232,8 @@ class TestEmployeeReminders(unittest.TestCase):
# teardown: enable emp 2 # teardown: enable emp 2
frappe.db.set_value('Employee', self.test_employee_2.name, { frappe.db.set_value('Employee', self.test_employee_2.name, {
'status': 'Left', 'status': 'Active',
'holiday_list': self.holiday_list_2 'holiday_list': self.holiday_list_2.name
}) })
def test_reminder_not_sent_if_no_holdays(self): def test_reminder_not_sent_if_no_holdays(self):