feat: Moved setup_program to test_program.py
This commit is contained in:
parent
a98e936d26
commit
8aa6ac7b03
@ -6,43 +6,11 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from erpnext.education.doctype.topic.test_topic import make_topic_and_linked_content
|
|
||||||
from erpnext.education.doctype.course.test_course import make_course_and_linked_topic
|
|
||||||
from erpnext.education.doctype.program.test_program import make_program_and_linked_courses
|
|
||||||
|
|
||||||
from erpnext.education.doctype.student.test_student import create_student
|
from erpnext.education.doctype.student.test_student import create_student
|
||||||
from erpnext.education.doctype.student.test_student import get_student
|
from erpnext.education.doctype.student.test_student import get_student
|
||||||
|
|
||||||
test_data = frappe._dict({
|
from erpnext.education.doctype.program.test_program import setup_program
|
||||||
"program_name": "_Test Program",
|
|
||||||
"course": [{
|
|
||||||
"course_name": "_Test Course 1",
|
|
||||||
"topic": [
|
|
||||||
{
|
|
||||||
"topic_name": "_Test Topic 1-1",
|
|
||||||
"content": [{
|
|
||||||
"type": "Article",
|
|
||||||
"name": "_Test Article 1-1"
|
|
||||||
},{
|
|
||||||
"type": "Article",
|
|
||||||
"name": "_Test Article 1-2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"topic_name": "_Test Topic 1-2",
|
|
||||||
"content": [{
|
|
||||||
"type": "Article",
|
|
||||||
"name": "_Test Article 1-3"
|
|
||||||
},{
|
|
||||||
"type": "Article",
|
|
||||||
"name": "_Test Article 1-4"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
class TestCourseEnrollment(unittest.TestCase):
|
class TestCourseEnrollment(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -60,6 +28,7 @@ class TestCourseEnrollment(unittest.TestCase):
|
|||||||
progress = course_enrollment.get_progress(student)
|
progress = course_enrollment.get_progress(student)
|
||||||
finished = {'content': '_Test Article 1-1', 'content_type': 'Article', 'is_complete': True}
|
finished = {'content': '_Test Article 1-1', 'content_type': 'Article', 'is_complete': True}
|
||||||
self.assertTrue(finished in progress)
|
self.assertTrue(finished in progress)
|
||||||
|
frappe.db.rollback()
|
||||||
|
|
||||||
|
|
||||||
def make_course_activity(enrollment, content_type, content):
|
def make_course_activity(enrollment, content_type, content):
|
||||||
@ -75,16 +44,3 @@ def make_course_activity(enrollment, content_type, content):
|
|||||||
"activity_date": frappe.utils.datetime.datetime.now()
|
"activity_date": frappe.utils.datetime.datetime.now()
|
||||||
}).insert()
|
}).insert()
|
||||||
return activity
|
return activity
|
||||||
|
|
||||||
def setup_program():
|
|
||||||
topic_list = [course['topic'] for course in test_data['course']]
|
|
||||||
for topic in topic_list[0]:
|
|
||||||
make_topic_and_linked_content(topic['topic_name'], topic['content'])
|
|
||||||
|
|
||||||
all_courses_list = [{'course': course['course_name'], 'topic': [topic['topic_name'] for topic in course['topic']]} for course in test_data['course']] # returns [{'course': 'Applied Math', 'topic': ['Trignometry', 'Geometry']}]
|
|
||||||
for course in all_courses_list:
|
|
||||||
make_course_and_linked_topic(course['course'], course['topic'])
|
|
||||||
|
|
||||||
course_list = [course['course_name'] for course in test_data['course']]
|
|
||||||
program = make_program_and_linked_courses(test_data.program_name, course_list)
|
|
||||||
return program
|
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
# See license.txt
|
# See license.txt
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from erpnext.education.doctype.course.test_course import make_course
|
from erpnext.education.doctype.course.test_course import make_course
|
||||||
|
from erpnext.education.doctype.topic.test_topic import make_topic_and_linked_content
|
||||||
|
from erpnext.education.doctype.course.test_course import make_course_and_linked_topic
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# test_records = frappe.get_test_records('Program')
|
test_data = frappe.get_test_records('Program')
|
||||||
|
|
||||||
class TestProgram(unittest.TestCase):
|
class TestProgram(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -42,3 +44,15 @@ def make_program_and_linked_courses(program_name, course_name_list):
|
|||||||
program.save()
|
program.save()
|
||||||
return program
|
return program
|
||||||
|
|
||||||
|
def setup_program():
|
||||||
|
topic_list = [course['topic'] for course in test_data['course']]
|
||||||
|
for topic in topic_list[0]:
|
||||||
|
make_topic_and_linked_content(topic['topic_name'], topic['content'])
|
||||||
|
|
||||||
|
all_courses_list = [{'course': course['course_name'], 'topic': [topic['topic_name'] for topic in course['topic']]} for course in test_data['course']] # returns [{'course': 'Applied Math', 'topic': ['Trignometry', 'Geometry']}]
|
||||||
|
for course in all_courses_list:
|
||||||
|
make_course_and_linked_topic(course['course'], course['topic'])
|
||||||
|
|
||||||
|
course_list = [course['course_name'] for course in test_data['course']]
|
||||||
|
program = make_program_and_linked_courses(test_data['program_name'], course_list)
|
||||||
|
return program
|
@ -1,12 +1,27 @@
|
|||||||
[
|
{
|
||||||
{
|
"program_name": "_Test Program",
|
||||||
"program_name": "_Test Program",
|
"course": [{
|
||||||
"program_code": "_TP1",
|
"course_name": "_Test Course 1",
|
||||||
"program_abbreviation": "TP1"
|
"topic": [{
|
||||||
},
|
"topic_name": "_Test Topic 1-1",
|
||||||
{
|
"content": [{
|
||||||
"program_name": "_Test Program 2",
|
"type": "Article",
|
||||||
"program_code": "_TP2",
|
"name": "_Test Article 1-1"
|
||||||
"program_abbreviation": "TP2"
|
}, {
|
||||||
}
|
"type": "Article",
|
||||||
]
|
"name": "_Test Article 1-2"
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"topic_name": "_Test Topic 1-2",
|
||||||
|
"content": [{
|
||||||
|
"type": "Article",
|
||||||
|
"name": "_Test Article 1-3"
|
||||||
|
}, {
|
||||||
|
"type": "Article",
|
||||||
|
"name": "_Test Article 1-4"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user