Adding Test Utils

This commit is contained in:
scmmishra 2018-12-12 11:29:08 +05:30 committed by Aditya Hase
parent c51f738b03
commit 6663ca1d7f
5 changed files with 36 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

0
erpnext/www/test_lms.py Normal file
View File