From 6663ca1d7fed7c4dcb5df7e7613c98892014732a Mon Sep 17 00:00:00 2001 From: scmmishra Date: Wed, 12 Dec 2018 11:29:08 +0530 Subject: [PATCH] Adding Test Utils --- .../education/doctype/course/test_course.py | 8 ++++++ .../education/doctype/program/test_program.py | 25 +++++++++++++++++++ erpnext/education/doctype/student/student.py | 1 - .../education/doctype/student/test_student.py | 5 ++-- erpnext/www/test_lms.py | 0 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 erpnext/www/test_lms.py diff --git a/erpnext/education/doctype/course/test_course.py b/erpnext/education/doctype/course/test_course.py index b18f4a94be..9e0d1850f2 100644 --- a/erpnext/education/doctype/course/test_course.py +++ b/erpnext/education/doctype/course/test_course.py @@ -10,3 +10,11 @@ import unittest class TestCourse(unittest.TestCase): pass + +def make_course(name): + course = frappe.get_doc({ + "doctype": "Program", + "course_name": name, + "course_code": name + }).insert() + return course.name \ No newline at end of file diff --git a/erpnext/education/doctype/program/test_program.py b/erpnext/education/doctype/program/test_program.py index a4accdaaf7..c67f39383d 100644 --- a/erpnext/education/doctype/program/test_program.py +++ b/erpnext/education/doctype/program/test_program.py @@ -2,6 +2,7 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # See license.txt from __future__ import unicode_literals +from erpnext.education.doctype.course.test_course import make_course import frappe import unittest @@ -10,3 +11,27 @@ import unittest class TestProgram(unittest.TestCase): pass + + +def make_program(name): + program = frappe.get_doc({ + "doctype": "Program", + "program_name": name, + "program_code": name, + "is_published": True, + "is_featured": True, + }).insert() + return program.name + +def make_program_and_linked_courses(program_name, course_name_list): + try: + program = frappe.get_doc("Program", program_name) + except frappe.DoesNotExistError: + make_program(program_name) + program = frappe.get_doc("Program", program_name) + course_list = [make_course(course_name) for course_name in course_name_list] + for course in course_list: + program.append("courses", {"course": course}) + program.save() + return program.name + diff --git a/erpnext/education/doctype/student/student.py b/erpnext/education/doctype/student/student.py index f6360c38d2..0f126ca991 100644 --- a/erpnext/education/doctype/student/student.py +++ b/erpnext/education/doctype/student/student.py @@ -55,7 +55,6 @@ class Student(Document): student_user.save() self.user = student_user.name self.save() - frappe.publish_realtime('enroll_student_progress', {"progress": [4, 4]}, user=frappe.session.user) update_password_link = student_user.reset_password() print(update_password_link) diff --git a/erpnext/education/doctype/student/test_student.py b/erpnext/education/doctype/student/test_student.py index cc6537f865..81e809e72e 100644 --- a/erpnext/education/doctype/student/test_student.py +++ b/erpnext/education/doctype/student/test_student.py @@ -2,11 +2,12 @@ # Copyright (c) 2015, Frappe Technologies and Contributors # See license.txt 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 import frappe import unittest -# test_records = frappe.get_test_records('Student') - +test_records = frappe.get_test_records('Student') class TestStudent(unittest.TestCase): pass diff --git a/erpnext/www/test_lms.py b/erpnext/www/test_lms.py new file mode 100644 index 0000000000..e69de29bb2