From 21823f5f66fa5157c3cca37f6786572102666161 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Thu, 14 Mar 2019 15:44:01 +0530 Subject: [PATCH] feat: Added test for program_enrollment --- .../test_program_enrollment.py | 18 ++++++++++++++++-- .../education/doctype/student/test_student.py | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/erpnext/education/doctype/program_enrollment/test_program_enrollment.py b/erpnext/education/doctype/program_enrollment/test_program_enrollment.py index c26e89920b0..c6cbee1b75a 100644 --- a/erpnext/education/doctype/program_enrollment/test_program_enrollment.py +++ b/erpnext/education/doctype/program_enrollment/test_program_enrollment.py @@ -6,7 +6,21 @@ from __future__ import unicode_literals import frappe import unittest -# test_records = frappe.get_test_records('Program Enrollment') +from erpnext.education.doctype.student.test_student import create_student +from erpnext.education.doctype.student.test_student import get_student +from erpnext.education.doctype.program.test_program import make_program_and_linked_courses +from erpnext.education.doctype.course_activity.test_course_activity import make_course_activity class TestProgramEnrollment(unittest.TestCase): - pass + + 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_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()) + frappe.db.rollback() \ No newline at end of file diff --git a/erpnext/education/doctype/student/test_student.py b/erpnext/education/doctype/student/test_student.py index b319624dbdb..8610edbf282 100644 --- a/erpnext/education/doctype/student/test_student.py +++ b/erpnext/education/doctype/student/test_student.py @@ -40,6 +40,7 @@ class TestStudent(unittest.TestCase): 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()) + frappe.db.rollback() def create_student(student_dict): student = get_student(student_dict['email'])