feat: Added lms tests for student doctype

This commit is contained in:
scmmishra 2019-03-06 15:26:41 +05:30
parent 92ab107b60
commit bcfe6f024f

View File

@ -10,4 +10,27 @@ import unittest
test_records = frappe.get_test_records('Student') test_records = frappe.get_test_records('Student')
class TestStudent(unittest.TestCase): class TestStudent(unittest.TestCase):
pass def setUp(self):
create_student({"first_name": "_Test Name", "last_name": "_Test Last Name", "email": "_test_student@example.com"})
def test_create_student_user(self):
self.assertTrue(bool(frappe.db.exists("User", "_test_student@example.com")))
frappe.db.rollback()
def create_student(student_dict):
student = get_student(student_dict['email'])
if not student:
student = frappe.get_doc({
"doctype": "Student",
"first_name": student_dict['first_name'],
"last_name": student_dict['last_name'],
"student_email_id": student_dict['email']
}).insert()
return student
def get_student(email):
try:
student_id = frappe.get_all("Student", {"student_email_id": email}, ["name"])[0].name
return frappe.get_doc("Student", student_id)
except IndexError:
return None