fix(assessment_result): student must be in group (#15255)
* fix(assessment_result): student must be in group * fix(test_student_group): raise correct exception * fix(unused-import): assessment-plan.py * fix(tests) * fix(tests) * fix(test) * fix(tests)
This commit is contained in:
parent
1b73505391
commit
a2288ff8e7
@ -0,0 +1,10 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
class StudentNotInGroupError(frappe.ValidationError): pass
|
||||
|
||||
def validate_student_belongs_to_group(student, student_group):
|
||||
groups = frappe.db.get_all('Student Group Student', ['parent'], dict(student = student, active=1))
|
||||
if not student_group in [d.parent for d in groups]:
|
||||
frappe.throw(_('Student {0} does not belong to group {1}').format(frappe.bold(student), frappe.bold(student_group)),
|
||||
StudentNotInGroupError)
|
@ -3,16 +3,6 @@
|
||||
|
||||
|
||||
frappe.ui.form.on("Assessment Plan", {
|
||||
setup: function(frm) {
|
||||
frm.add_fetch("student_group", "course", "course");
|
||||
frm.add_fetch("student_group", "program", "program");
|
||||
frm.add_fetch("student_group", "academic_year", "academic_year");
|
||||
frm.add_fetch("student_group", "academic_term", "academic_term");
|
||||
frm.add_fetch("examiner", "instructor_name", "examiner_name");
|
||||
frm.add_fetch("supervisor", "instructor_name", "supervisor_name");
|
||||
frm.add_fetch("course", "default_grading_scale", "grading_scale");
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
frm.set_query("assessment_group", function(doc, cdt, cdn) {
|
||||
return{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,38 +9,26 @@ from frappe import _
|
||||
|
||||
class AssessmentPlan(Document):
|
||||
def validate(self):
|
||||
self.set_missing_field()
|
||||
self.validate_overlap()
|
||||
self.validate_max_score()
|
||||
self.validate_assessment_criteria()
|
||||
|
||||
def set_missing_field(self):
|
||||
if self.student_group:
|
||||
academic_term, academic_year, program, course = frappe.get_value("Student Group", self.student_group,
|
||||
["academic_term", "academic_year", "program", "course"])
|
||||
self.academic_term = academic_term
|
||||
self.academic_year = academic_year
|
||||
if program:
|
||||
self.program = program
|
||||
if course and not self.course: #pylint: disable=E0203
|
||||
self.course = course
|
||||
|
||||
def validate_overlap(self):
|
||||
"""Validates overlap for Student Group, Instructor, Room"""
|
||||
|
||||
|
||||
from erpnext.education.utils import validate_overlap_for
|
||||
|
||||
#Validate overlapping course schedules.
|
||||
if self.student_group:
|
||||
validate_overlap_for(self, "Course Schedule", "student_group")
|
||||
|
||||
|
||||
validate_overlap_for(self, "Course Schedule", "instructor")
|
||||
validate_overlap_for(self, "Course Schedule", "room")
|
||||
|
||||
#validate overlapping assessment schedules.
|
||||
if self.student_group:
|
||||
validate_overlap_for(self, "Assessment Plan", "student_group")
|
||||
|
||||
|
||||
validate_overlap_for(self, "Assessment Plan", "room")
|
||||
validate_overlap_for(self, "Assessment Plan", "supervisor", self.supervisor)
|
||||
|
||||
|
@ -2,18 +2,6 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Assessment Result", {
|
||||
setup: function(frm) {
|
||||
frm.add_fetch("student", "title", "student_name");
|
||||
frm.add_fetch("assessment_plan", "course", "course");
|
||||
frm.add_fetch("assessment_plan", "program", "program");
|
||||
frm.add_fetch("assessment_plan", "academic_year", "academic_year");
|
||||
frm.add_fetch("assessment_plan", "academic_term", "academic_term");
|
||||
frm.add_fetch("assessment_plan", "grading_scale", "grading_scale");
|
||||
frm.add_fetch("assessment_plan", "student_group", "student_group");
|
||||
frm.add_fetch("assessment_plan", "assessment_group", "assessment_group");
|
||||
frm.add_fetch("assessment_plan", "maximum_assessment_score", "maximum_score");
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
frm.set_query('assessment_plan', function(){
|
||||
return {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,28 +10,15 @@ from frappe.model.document import Document
|
||||
from erpnext.education.api import get_grade
|
||||
from erpnext.education.api import get_assessment_details
|
||||
from frappe.utils.csvutils import getlink
|
||||
|
||||
import erpnext.education
|
||||
|
||||
class AssessmentResult(Document):
|
||||
def validate(self):
|
||||
self.set_missing_values()
|
||||
erpnext.education.validate_student_belongs_to_group(self.student, self.student_group)
|
||||
self.validate_maximum_score()
|
||||
self.validate_grade()
|
||||
self.validate_duplicate()
|
||||
|
||||
def set_missing_values(self):
|
||||
if self.student and not self.student_name:
|
||||
self.student_name = frappe.db.get_value("Student", self.student, "title")
|
||||
assessment_plan_details = frappe.get_value("Assessment Plan", self.assessment_plan, ["academic_term",
|
||||
"academic_year", "program", "course", "grading_scale", "assessment_group", "student_group",
|
||||
"maximum_assessment_score"], as_dict=1)
|
||||
|
||||
for field in assessment_plan_details:
|
||||
if field != "maximum_assessment_score":
|
||||
setattr(self, field, assessment_plan_details[field])
|
||||
else:
|
||||
self.maximum_score = assessment_plan_details[field]
|
||||
|
||||
def validate_maximum_score(self):
|
||||
assessment_details = get_assessment_details(self.assessment_plan)
|
||||
max_scores = {}
|
||||
@ -42,7 +29,7 @@ class AssessmentResult(Document):
|
||||
d.maximum_score = max_scores.get(d.assessment_criteria)
|
||||
if d.score > d.maximum_score:
|
||||
frappe.throw(_("Score cannot be greater than Maximum Score"))
|
||||
|
||||
|
||||
def validate_grade(self):
|
||||
self.total_score = 0.0
|
||||
for d in self.details:
|
||||
|
@ -1,216 +1,226 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:grading_scale_name",
|
||||
"beta": 0,
|
||||
"creation": "2016-08-26 03:06:53.922972",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:grading_scale_name",
|
||||
"beta": 0,
|
||||
"creation": "2016-08-26 03:06:53.922972",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "grading_scale_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Grading Scale Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "grading_scale_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Grading Scale Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Description",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "grading_intervals_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Grading Scale Intervals",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "grading_intervals_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Grading Scale Intervals",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "intervals",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Intervals",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Grading Scale Interval",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "intervals",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Intervals",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Grading Scale Interval",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Amended From",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"options": "Grading Scale",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Amended From",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"options": "Grading Scale",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Description",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 1,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-11-10 19:07:22.001040",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Education",
|
||||
"name": "Grading Scale",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 1,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-08-30 00:34:03.368432",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Education",
|
||||
"name": "Grading Scale",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Academics User",
|
||||
"set_user_permissions": 0,
|
||||
"share": 1,
|
||||
"submit": 1,
|
||||
"amend": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Academics User",
|
||||
"set_user_permissions": 0,
|
||||
"share": 1,
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"restrict_to_domain": "Education",
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"title_field": "",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"restrict_to_domain": "Education",
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"title_field": "",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
"date_of_birth": "2000-01-01",
|
||||
"gender": "Male",
|
||||
"blood_group": "A+"
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
"first_name": "_Test",
|
||||
@ -17,7 +17,7 @@
|
||||
"date_of_birth": "2000-01-01",
|
||||
"gender": "Male",
|
||||
"blood_group": "A+"
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
"first_name": "_Test",
|
||||
@ -27,6 +27,26 @@
|
||||
"date_of_birth": "2000-01-01",
|
||||
"gender": "Male",
|
||||
"blood_group": "A+"
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
"first_name": "_Test",
|
||||
"middle_name": "Student",
|
||||
"last_name": "Name 3",
|
||||
"program": "TC101",
|
||||
"date_of_birth": "2000-01-01",
|
||||
"gender": "Male",
|
||||
"blood_group": "A+"
|
||||
|
||||
},
|
||||
{
|
||||
"first_name": "_Test",
|
||||
"middle_name": "Student",
|
||||
"last_name": "Name 4",
|
||||
"program": "TC101",
|
||||
"date_of_birth": "2000-01-01",
|
||||
"gender": "Male",
|
||||
"blood_group": "A+"
|
||||
|
||||
}
|
||||
]
|
@ -5,23 +5,38 @@ from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest
|
||||
from frappe.utils.make_random import get_random
|
||||
import erpnext.education
|
||||
|
||||
def get_random_group():
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "Student Group",
|
||||
"student_group_name": "_Test Student Group-" + frappe.generate_hash(length=5),
|
||||
"group_based_on": "Activity"
|
||||
}).insert()
|
||||
|
||||
student_list = frappe.get_all('Student', limit=5)
|
||||
|
||||
doc.extend("students", [{"student":d.name, "active": 1} for d in student_list])
|
||||
doc.save()
|
||||
|
||||
return doc
|
||||
|
||||
class TestStudentGroup(unittest.TestCase):
|
||||
def test_student_roll_no(self):
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "Student Group",
|
||||
"student_group_name": "_Test Student Group R",
|
||||
"group_based_on": "Activity"
|
||||
}).insert()
|
||||
doc = get_random_group()
|
||||
self.assertEqual(max([d.group_roll_number for d in doc.students]), len(doc.students))
|
||||
|
||||
student_list = []
|
||||
while len(student_list) < 3:
|
||||
s = get_random("Student")
|
||||
if s not in student_list:
|
||||
student_list.append(s)
|
||||
def test_in_group(self):
|
||||
doc = get_random_group()
|
||||
|
||||
doc.extend("students", [{"student":d} for d in student_list])
|
||||
last_student = doc.students[-1].student
|
||||
|
||||
# remove last student
|
||||
doc.students = doc.students[:-1]
|
||||
doc.save()
|
||||
self.assertEqual(max([d.group_roll_number for d in doc.students]), 3)
|
||||
|
||||
self.assertRaises(erpnext.education.StudentNotInGroupError,
|
||||
erpnext.education.validate_student_belongs_to_group, last_student, doc.name)
|
||||
|
||||
# safe, don't throw validation
|
||||
erpnext.education.validate_student_belongs_to_group(doc.students[0].student, doc.name)
|
||||
|
@ -31,17 +31,20 @@ class TestEmployeeOnboarding(unittest.TestCase):
|
||||
onboarding.status = 'Pending'
|
||||
onboarding.insert()
|
||||
onboarding.submit()
|
||||
self.assertEqual(onboarding.project, 'Employee Onboarding : Test Researcher - test@researcher.com')
|
||||
self.assertRaises(IncompleteTaskError, make_employee, onboarding.name)
|
||||
return onboarding
|
||||
|
||||
def test_employee_onboarding_completed_task(self):
|
||||
doc = self.test_employee_onboarding_incomplete_task()
|
||||
project = frappe.get_doc('Project', doc.project)
|
||||
self.assertEqual(onboarding.project, 'Employee Onboarding : Test Researcher - test@researcher.com')
|
||||
|
||||
# don't allow making employee if onboarding is not complete
|
||||
self.assertRaises(IncompleteTaskError, make_employee, onboarding.name)
|
||||
|
||||
# complete the task
|
||||
project = frappe.get_doc('Project', onboarding.project)
|
||||
project.tasks[0].status = 'Closed'
|
||||
project.save()
|
||||
doc.reload()
|
||||
employee = make_employee(doc.name)
|
||||
|
||||
# make employee
|
||||
onboarding.reload()
|
||||
employee = make_employee(onboarding.name)
|
||||
employee.first_name = employee.employee_name
|
||||
employee.date_of_joining = nowdate()
|
||||
employee.date_of_birth = '1990-05-08'
|
||||
|
@ -546,7 +546,7 @@
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Leave Period",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
@ -676,7 +676,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-08-29 06:33:54.651196",
|
||||
"modified": "2018-08-29 23:52:52.683844",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Leave Allocation",
|
||||
|
@ -82,6 +82,7 @@ frappe.ui.form.on('Leave Period', {
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
d.hide();
|
||||
frm.reload_doc();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -53,24 +53,6 @@ def before_tests():
|
||||
frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 0)
|
||||
enable_all_roles_and_domains()
|
||||
|
||||
if not frappe.db.exists('Company', 'Woocommerce'):
|
||||
company = frappe.new_doc("Company")
|
||||
company.company_name = "Woocommerce"
|
||||
company.abbr = "W"
|
||||
company.default_currency = "INR"
|
||||
company.save()
|
||||
|
||||
woo_settings = frappe.get_doc("Woocommerce Settings")
|
||||
if not woo_settings.secret:
|
||||
woo_settings.secret = "ec434676aa1de0e502389f515c38f89f653119ab35e9117c7a79e576"
|
||||
woo_settings.woocommerce_server_url = "https://woocommerce.mntechnique.com/"
|
||||
woo_settings.api_consumer_key = "ck_fd43ff5756a6abafd95fadb6677100ce95a758a1"
|
||||
woo_settings.api_consumer_secret = "cs_94360a1ad7bef7fa420a40cf284f7b3e0788454e"
|
||||
woo_settings.enable_sync = 1
|
||||
woo_settings.tax_account = "Sales Expenses - W"
|
||||
woo_settings.f_n_f_account = "Expenses - W"
|
||||
woo_settings.save(ignore_permissions=True)
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -2,9 +2,24 @@ import unittest, frappe, requests, os, time, erpnext
|
||||
from erpnext.erpnext_integrations.connectors.woocommerce_connection import order
|
||||
|
||||
class TestWoocommerce(unittest.TestCase):
|
||||
# def test_woocommerce_request(self):
|
||||
# r = emulate_request()
|
||||
# self.assertTrue(r.status_code == 200)
|
||||
def setup(self):
|
||||
if not frappe.db.exists('Company', 'Woocommerce'):
|
||||
company = frappe.new_doc("Company")
|
||||
company.company_name = "Woocommerce"
|
||||
company.abbr = "W"
|
||||
company.default_currency = "INR"
|
||||
company.save()
|
||||
|
||||
woo_settings = frappe.get_doc("Woocommerce Settings")
|
||||
if not woo_settings.secret:
|
||||
woo_settings.secret = "ec434676aa1de0e502389f515c38f89f653119ab35e9117c7a79e576"
|
||||
woo_settings.woocommerce_server_url = "https://woocommerce.mntechnique.com/"
|
||||
woo_settings.api_consumer_key = "ck_fd43ff5756a6abafd95fadb6677100ce95a758a1"
|
||||
woo_settings.api_consumer_secret = "cs_94360a1ad7bef7fa420a40cf284f7b3e0788454e"
|
||||
woo_settings.enable_sync = 1
|
||||
woo_settings.tax_account = "Sales Expenses - W"
|
||||
woo_settings.f_n_f_account = "Expenses - W"
|
||||
woo_settings.save(ignore_permissions=True)
|
||||
|
||||
def test_sales_order_for_woocommerece(self):
|
||||
data = {"id":75,"parent_id":0,"number":"74","order_key":"wc_order_5aa1281c2dacb","created_via":"checkout","version":"3.3.3","status":"processing","currency":"INR","date_created":"2018-03-08T12:10:04","date_created_gmt":"2018-03-08T12:10:04","date_modified":"2018-03-08T12:10:04","date_modified_gmt":"2018-03-08T12:10:04","discount_total":"0.00","discount_tax":"0.00","shipping_total":"150.00","shipping_tax":"0.00","cart_tax":"0.00","total":"649.00","total_tax":"0.00","prices_include_tax":False,"customer_id":12,"customer_ip_address":"103.54.99.5","customer_user_agent":"mozilla\\/5.0 (x11; linux x86_64) applewebkit\\/537.36 (khtml, like gecko) chrome\\/64.0.3282.186 safari\\/537.36","customer_note":"","billing":{"first_name":"Tony","last_name":"Stark","company":"Woocommerce","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN","email":"tony@gmail.com","phone":"123457890"},"shipping":{"first_name":"Tony","last_name":"Stark","company":"","address_1":"Mumbai","address_2":"","city":"Dadar","state":"MH","postcode":"123","country":"IN"},"payment_method":"cod","payment_method_title":"Cash on delivery","transaction_id":"","date_paid":"","date_paid_gmt":"","date_completed":"","date_completed_gmt":"","cart_hash":"8e76b020d5790066496f244860c4703f","meta_data":[],"line_items":[{"id":80,"name":"Marvel","product_id":56,"variation_id":0,"quantity":1,"tax_class":"","subtotal":"499.00","subtotal_tax":"0.00","total":"499.00","total_tax":"0.00","taxes":[],"meta_data":[],"sku":"","price":499}],"tax_lines":[],"shipping_lines":[{"id":81,"method_title":"Flat rate","method_id":"flat_rate:1","total":"150.00","total_tax":"0.00","taxes":[],"meta_data":[{"id":623,"key":"Items","value":"Marvel × 1"}]}],"fee_lines":[],"coupon_lines":[],"refunds":[]}
|
||||
|
Loading…
x
Reference in New Issue
Block a user