feat: Moved setup_program to test_program.py
diff --git a/erpnext/education/doctype/course_enrollment/test_course_enrollment.py b/erpnext/education/doctype/course_enrollment/test_course_enrollment.py
index 101bed4..3ebf0b9 100644
--- a/erpnext/education/doctype/course_enrollment/test_course_enrollment.py
+++ b/erpnext/education/doctype/course_enrollment/test_course_enrollment.py
@@ -6,43 +6,11 @@
import frappe
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 get_student
-test_data = frappe._dict({
- "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"
- }
- ]
- }
- ]
- }]
-})
+from erpnext.education.doctype.program.test_program import setup_program
class TestCourseEnrollment(unittest.TestCase):
def setUp(self):
@@ -60,6 +28,7 @@
progress = course_enrollment.get_progress(student)
finished = {'content': '_Test Article 1-1', 'content_type': 'Article', 'is_complete': True}
self.assertTrue(finished in progress)
+ frappe.db.rollback()
def make_course_activity(enrollment, content_type, content):
@@ -75,16 +44,3 @@
"activity_date": frappe.utils.datetime.datetime.now()
}).insert()
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
diff --git a/erpnext/education/doctype/program/test_program.py b/erpnext/education/doctype/program/test_program.py
index 4c48aca..54e780b 100644
--- a/erpnext/education/doctype/program/test_program.py
+++ b/erpnext/education/doctype/program/test_program.py
@@ -3,11 +3,13 @@
# See license.txt
from __future__ import unicode_literals
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 unittest
-# test_records = frappe.get_test_records('Program')
+test_data = frappe.get_test_records('Program')
class TestProgram(unittest.TestCase):
def setUp(self):
@@ -42,3 +44,15 @@
program.save()
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
\ No newline at end of file
diff --git a/erpnext/education/doctype/program/test_records.json b/erpnext/education/doctype/program/test_records.json
index e5eda70..db4b1b4 100644
--- a/erpnext/education/doctype/program/test_records.json
+++ b/erpnext/education/doctype/program/test_records.json
@@ -1,12 +1,27 @@
-[
- {
- "program_name": "_Test Program",
- "program_code": "_TP1",
- "program_abbreviation": "TP1"
- },
- {
- "program_name": "_Test Program 2",
- "program_code": "_TP2",
- "program_abbreviation": "TP2"
- }
-]
+{
+ "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"
+ }]
+ }
+ ]
+ }]
+}
\ No newline at end of file