diff --git a/erpnext/education/doctype/student/test_student.py b/erpnext/education/doctype/student/test_student.py index e3bce9ab97..b319624dbd 100644 --- a/erpnext/education/doctype/student/test_student.py +++ b/erpnext/education/doctype/student/test_student.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from frappe.test_runner import make_test_records from erpnext.education.doctype.program.test_program import make_program_and_linked_courses +from erpnext.education.doctype.course.test_course import make_course import frappe import unittest @@ -12,11 +13,34 @@ test_records = frappe.get_test_records('Student') class TestStudent(unittest.TestCase): def setUp(self): create_student({"first_name": "_Test Name", "last_name": "_Test Last Name", "email": "_test_student@example.com"}) + make_program_and_linked_courses("_Test Program 1", ["_Test Course 1", "_Test Course 2"]) def test_create_student_user(self): self.assertTrue(bool(frappe.db.exists("User", "_test_student@example.com"))) frappe.db.rollback() + def test_enroll_in_program(self): + student = get_student("_test_student@example.com") + enrollment = student.enroll_in_program("_Test Program 1") + test_enrollment = frappe.get_all("Program Enrollment", filters={"student": student.name, "Program": "_Test Program 1"}) + self.assertTrue(len(test_enrollment)) + self.assertEqual(test_enrollment[0]['name'], enrollment.name) + frappe.db.rollback() + + def test_get_program_enrollments(self): + student = get_student("_test_student@example.com") + enrollment = student.enroll_in_program("_Test Program 1") + program_enrollments = student.get_program_enrollments() + self.assertTrue("_Test Program 1" in program_enrollments) + frappe.db.rollback() + + def test_get_all_course_enrollments(self): + student = get_student("_test_student@example.com") + enrollment = student.enroll_in_program("_Test Program 1") + course_enrollments = student.get_all_course_enrollments() + self.assertTrue("_Test Course 1" in course_enrollments.keys()) + self.assertTrue("_Test Course 2" in course_enrollments.keys()) + def create_student(student_dict): student = get_student(student_dict['email']) if not student: