[Fix] fixed test cases for schools
This commit is contained in:
parent
7b13c11182
commit
7dae3e1ed4
@ -1,14 +1,17 @@
|
||||
[
|
||||
{
|
||||
"course_name": "_Test Course",
|
||||
"course_code": "TC100"
|
||||
"course_code": "TC100",
|
||||
"course_abbreviation": "TC"
|
||||
},
|
||||
{
|
||||
"course_name": "_Test Course 1",
|
||||
"course_code": "TC101"
|
||||
"course_code": "TC101",
|
||||
"course_abbreviation": "TC1"
|
||||
},
|
||||
{
|
||||
"course_name": "_Test Course 2",
|
||||
"course_code": "TC102"
|
||||
"course_code": "TC102",
|
||||
"course_abbreviation": "TC2"
|
||||
}
|
||||
]
|
@ -24,27 +24,27 @@ class TestCourseSchedule(unittest.TestCase):
|
||||
cs1 = make_course_schedule_test_record(simulate= True)
|
||||
|
||||
cs2 = make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
|
||||
student_group="_Test Student Group 1", room="RM0002", do_not_save= 1)
|
||||
student_group="TC2-TP-2014-2015-_Test Academic Term", room="RM0002", do_not_save= 1)
|
||||
self.assertRaises(OverlapError, cs2.save)
|
||||
|
||||
def test_room_conflict(self):
|
||||
cs1 = make_course_schedule_test_record(simulate= True)
|
||||
|
||||
cs2 = make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
|
||||
student_group="_Test Student Group 1", instructor="_T-Instructor-00002", do_not_save= 1)
|
||||
student_group="TC2-TP-2014-2015-_Test Academic Term", instructor="_T-Instructor-00002", do_not_save= 1)
|
||||
self.assertRaises(OverlapError, cs2.save)
|
||||
|
||||
def test_no_conflict(self):
|
||||
cs1 = make_course_schedule_test_record(simulate= True)
|
||||
|
||||
make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
|
||||
student_group="_Test Student Group 1", instructor="_T-Instructor-00002", room="RM0002")
|
||||
student_group="TC2-TP-2014-2015-_Test Academic Term", instructor="_T-Instructor-00002", room="RM0002")
|
||||
|
||||
def make_course_schedule_test_record(**args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
course_schedule = frappe.new_doc("Course Schedule")
|
||||
course_schedule.student_group = args.student_group or "_Test Student Group"
|
||||
course_schedule.student_group = args.student_group or "TC-TP-2014-2015-_Test Academic Term"
|
||||
course_schedule.course = args.course or "_Test Course"
|
||||
course_schedule.instructor = args.instructor or "_T-Instructor-00001"
|
||||
course_schedule.room = args.room or "RM0001"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_import": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 0,
|
||||
"autoname": "field:exam_name",
|
||||
"beta": 0,
|
||||
@ -480,7 +480,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2016-07-25 01:26:26.776581",
|
||||
"modified": "2016-07-25 06:24:11.126911",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Schools",
|
||||
"name": "Examination",
|
||||
|
@ -1,8 +1,10 @@
|
||||
[
|
||||
{
|
||||
"program_name": "_Test Program"
|
||||
"program_name": "_Test Program",
|
||||
"program_abbreviation": "TP"
|
||||
},
|
||||
{
|
||||
"program_name": "_Test Program 2"
|
||||
"program_name": "_Test Program 2",
|
||||
"program_abbreviation": "TP2"
|
||||
}
|
||||
]
|
||||
|
@ -556,7 +556,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2016-07-25 01:27:04.145185",
|
||||
"modified": "2016-07-25 06:23:57.581538",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Schools",
|
||||
"name": "Student",
|
||||
|
@ -8,9 +8,12 @@ from erpnext.schools.utils import validate_duplicate_student
|
||||
import frappe
|
||||
|
||||
class StudentBatch(Document):
|
||||
def validate(self):
|
||||
validate_duplicate_student(self.students)
|
||||
def autoname(self):
|
||||
prog_abb = frappe.db.get_value("Program", self.program, "program_abbreviation")
|
||||
if not prog_abb:
|
||||
prog_abb = self.program
|
||||
self.name = prog_abb + "-"+ self.student_batch_name + "-" + self.academic_year
|
||||
self.name = prog_abb + "-"+ self.student_batch_name + "-" + self.academic_year
|
||||
|
||||
def validate(self):
|
||||
validate_duplicate_student(self.students)
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "",
|
||||
"beta": 0,
|
||||
"creation": "2015-09-07 12:55:52.072792",
|
||||
@ -280,7 +280,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2016-07-25 01:32:57.819189",
|
||||
"modified": "2016-07-25 06:23:43.903111",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Schools",
|
||||
"name": "Student Group",
|
||||
|
@ -9,13 +9,7 @@ from frappe import _
|
||||
from erpnext.schools.utils import validate_duplicate_student
|
||||
|
||||
class StudentGroup(Document):
|
||||
def validate(self):
|
||||
self.set_name()
|
||||
self.validate_strength()
|
||||
self.validate_student_name()
|
||||
validate_duplicate_student(self.students)
|
||||
|
||||
def set_name(self):
|
||||
def autoname(self):
|
||||
self.name = frappe.db.get_value("Course", self.course, "course_abbreviation")
|
||||
if not self.name:
|
||||
self.name = self.course
|
||||
@ -31,6 +25,11 @@ class StudentGroup(Document):
|
||||
self.name += "-" + self.academic_year
|
||||
if self.academic_term:
|
||||
self.name += "-" + self.academic_term
|
||||
|
||||
def validate(self):
|
||||
self.validate_strength()
|
||||
self.validate_student_name()
|
||||
validate_duplicate_student(self.students)
|
||||
|
||||
def validate_strength(self):
|
||||
if self.max_strength and len(self.students) > self.max_strength:
|
||||
|
@ -1,13 +1,11 @@
|
||||
[
|
||||
{
|
||||
"group_name": "_Test Student Group",
|
||||
"program": "_Test Program",
|
||||
"course": "_Test Course",
|
||||
"academic_year": "2014-2015",
|
||||
"academic_term": "_Test Academic Term"
|
||||
},
|
||||
{
|
||||
"group_name": "_Test Student Group 1",
|
||||
"program": "_Test Program",
|
||||
"course": "_Test Course 2",
|
||||
"academic_year": "2014-2015",
|
||||
|
Loading…
Reference in New Issue
Block a user