From bcfe6f024f215c51ecc1ffd2e568ebf6081b1f03 Mon Sep 17 00:00:00 2001 From: scmmishra Date: Wed, 6 Mar 2019 15:26:41 +0530 Subject: [PATCH] feat: Added lms tests for student doctype --- .../education/doctype/student/test_student.py | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/erpnext/education/doctype/student/test_student.py b/erpnext/education/doctype/student/test_student.py index 81e809e72e..e3bce9ab97 100644 --- a/erpnext/education/doctype/student/test_student.py +++ b/erpnext/education/doctype/student/test_student.py @@ -10,4 +10,27 @@ import unittest test_records = frappe.get_test_records('Student') 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 \ No newline at end of file