+
-
+
+
+
+
+
+
+
+
Service-Learning Faculty
+
+ {% set instructorEmails = [] %}
+ {% for instructor in courseInstructors%}
+ {{ instructorEmails.append(instructor.email) or "" }}
+ {% endfor %}
+
+
+
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/database/base_data.py b/database/base_data.py
index 2cadf9643..87b76e7d1 100644
--- a/database/base_data.py
+++ b/database/base_data.py
@@ -6,28 +6,31 @@
terms = [
{
- "id": 7,
+ "id": 6,
"description": "Summer 2022",
"year": 2022,
"academicYear": "2021-2022",
"isSummer": True,
- "isCurrentTerm": False
+ "isCurrentTerm": False,
+ "termOrder": "2022-2"
},
{
- "id": 8,
+ "id": 7,
"description": "Fall 2022",
"year": 2022,
"academicYear": "2022-2023",
"isSummer": False,
- "isCurrentTerm": False
+ "isCurrentTerm": False,
+ "termOrder": "2022-3"
},
{
- "id": 9,
+ "id": 8,
"description": "Spring 2023",
"year": 2023,
"academicYear": "2022-2023",
"isSummer": False,
- "isCurrentTerm": False
+ "isCurrentTerm": False,
+ "termOrder": "2023-1"
},
]
Term.insert_many(terms).on_conflict_replace().execute()
@@ -95,6 +98,10 @@
{
"id": 3,
"status": "Approved"
+ },
+ {
+ "id": 4,
+ "status": "Imported"
}
]
CourseStatus.insert_many(coursestatus).on_conflict_replace().execute()
diff --git a/database/test_data.py b/database/test_data.py
index b6b94c514..527e24a06 100644
--- a/database/test_data.py
+++ b/database/test_data.py
@@ -324,47 +324,45 @@
"year": 2020,
"academicYear": "2020-2021",
"isSummer": False,
- "isCurrentTerm": False
+ "isCurrentTerm": False,
+ "termOrder": "2020-3"
},
{
"id": 2,
- "description": "Spring A 2021",
+ "description": "Spring 2021",
"year": 2021,
"academicYear": "2020-2021",
"isSummer": False,
- "isCurrentTerm": False
+ "isCurrentTerm": False,
+ "termOrder": "2021-1"
},
+
{
"id": 3,
- "description": "Spring B 2021",
- "year": 2021,
- "academicYear": "2020-2021",
- "isSummer": False,
- "isCurrentTerm": False
- },
- {
- "id": 4,
"description": "Summer 2021",
"year": 2021,
"academicYear": "2020-2021",
"isSummer": True,
- "isCurrentTerm": True
+ "isCurrentTerm": True,
+ "termOrder": "2021-2"
},
{
- "id": 5,
+ "id": 4,
"description": "Fall 2021",
"year": 2021,
"academicYear": "2021-2022",
"isSummer": False,
- "isCurrentTerm": False
+ "isCurrentTerm": False,
+ "termOrder": "2021-3"
},
{
- "id": 6,
+ "id": 5,
"description": "Spring 2022",
"year": 2022,
"academicYear": "2021-2022",
"isSummer": False,
- "isCurrentTerm": False
+ "isCurrentTerm": False,
+ "termOrder": "2022-1"
},
]
@@ -765,6 +763,7 @@
{
"id": 1,
"courseName": "Databases",
+ "courseAbbreviation": "",
"term": 3,
"status": 1,
"courseCredit": "",
@@ -776,6 +775,7 @@
{
"id": 2,
"courseName": "Spanish Help",
+ "courseAbbreviation": "SPN 104",
"term": 2,
"status": 2,
"courseCredit": "",
@@ -786,8 +786,9 @@
},
{
"id": 3,
- "courseName": "French Help",
- "term": 4,
+ "courseName": "Frenchy Help",
+ "courseAbbreviation": "FRN 103",
+ "term": 3,
"status": 3,
"courseCredit": "",
"createdBy": "ramsayb2",
@@ -798,6 +799,7 @@
{
"id": 4,
"courseName": "Testing",
+ "courseAbbreviation": "",
"term": 2,
"status": 1,
"courseCredit": "",
diff --git a/requirements.txt b/requirements.txt
index 1fb7fee19..42578d418 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -36,6 +36,7 @@ Jinja2==3.0.1
Mako==1.1.4
MarkupSafe==2.1.1
more-itertools==8.8.0
+openpyxl==3.1.2
ordered-set==4.0.2
packaging==20.9
peewee==3.14.4
@@ -55,6 +56,7 @@ pytest-watch==4.2.0
python-dateutil==2.8.2
python-editor==1.0.4
PyYAML==5.4.1
+regex ==2023.6.3
requests==2.25.1
selenium==3.141.0
six==1.16.0
diff --git a/tests/code/test_courseParticipants.py b/tests/code/test_courseParticipants.py
new file mode 100644
index 000000000..95da8114e
--- /dev/null
+++ b/tests/code/test_courseParticipants.py
@@ -0,0 +1,87 @@
+import pytest
+from flask import g
+from app import app
+from app.models import mainDB
+from app.models.term import Term
+from app.models.course import Course
+from app.models.courseParticipant import CourseParticipant
+from app.logic.serviceLearningCoursesData import parseUploadedFile, saveCourseParticipantsToDatabase
+
+@pytest.mark.integration
+def test_pushDataToDatabase():
+
+ with mainDB.atomic() as transaction:
+ courseParticipantPreview = {'Fall 2019' : {'CSC 226' : [['Ebenezer Ayisi', 'B00739736'], ['Finn Bledsoe', 'B00776544']]},
+ 'Spring 2020' : {'HIS 236' : [['Alex Bryant', 'B00708826']]},
+ 'Summer 2021' : {'CSC 450' : [['Tyler Parton', 'B00751360']]}}
+
+ assert Term.get_or_none(Term.description =="Fall 2019") == None
+ assert Term.get_or_none(Term.description == "Spring 2020") == None
+ assert Term.get_or_none(Term.description == 'Summer 2021') != None
+
+ assert Course.get_or_none(Course.courseAbbreviation == "CSC 226") == None
+ assert Course.get_or_none(Course.courseAbbreviation == "HIS 236") == None
+ assert Course.get_or_none(Course.courseAbbreviation == "CSC 450") == None
+
+ assert len(list(CourseParticipant.select())) == 5
+
+ with app.app_context():
+ g.current_user="ramsayb2"
+ saveCourseParticipantsToDatabase(courseParticipantPreview)
+
+ assert len(list(CourseParticipant.select())) == 9
+
+ getTestCourseParticipant = CourseParticipant.get_or_none(user_id = 'ayisie')
+ getTestTerm = Term.get_or_none(description = 'Fall 2019')
+ getTestCourse = Course.get_or_none(id = getTestCourseParticipant.course_id)
+ assert getTestCourse.courseAbbreviation == 'CSC 226'
+ assert getTestCourse.term_id == getTestTerm.id
+
+ getTestCourseParticipant = CourseParticipant.get_or_none(user_id = 'bledsoef')
+ getTestTerm = Term.get_or_none(description = 'Fall 2019')
+ getTestCourse = Course.get_or_none(id = getTestCourseParticipant.course_id)
+ assert getTestCourse.courseAbbreviation == 'CSC 226'
+ assert getTestCourse.term_id == getTestTerm.id
+
+ getTestCourseParticipant = CourseParticipant.get_or_none(user_id = 'bryanta')
+ getTestTerm = Term.get_or_none(description = 'Spring 2020')
+ getTestCourse = Course.get_or_none(id = getTestCourseParticipant.course_id)
+ assert getTestCourse.courseAbbreviation == 'HIS 236'
+ assert getTestCourse.term_id == getTestTerm.id
+
+ getTestCourseParticipant = CourseParticipant.get_or_none(user_id = 'partont')
+ getTestTerm = Term.get_or_none(description = 'Summer 2021')
+ getTestCourse = Course.get_or_none(id = getTestCourseParticipant.course_id)
+ assert getTestCourse.courseAbbreviation == 'CSC 450'
+ assert getTestCourse.term_id == getTestTerm.id
+
+
+ transaction.rollback()
+
+@pytest.mark.integration
+def test_parseUpload():
+ valid_file_path = 'tests/files/parseUpload_ValidTest.xlsx'
+ result = parseUploadedFile(valid_file_path)
+ assert isinstance(result, tuple)
+ assert len(result) == 3
+ errorFlag, courseParticipantPreview, previewCourseDisplayList = result
+
+ assert not errorFlag
+ assert previewCourseDisplayList
+ assert isinstance(courseParticipantPreview, dict)
+ assert len(courseParticipantPreview) == 4
+
+ invalid_file_path = 'tests/files/parseUpload_InvalidTest.xlsx'
+ result = parseUploadedFile(invalid_file_path)
+ assert isinstance(result, tuple)
+ assert len(result) == 3
+ errorFlag, courseParticipantPreview, previewCourseDisplayList = result
+
+ assert errorFlag
+ assert previewCourseDisplayList
+ assert isinstance(courseParticipantPreview, dict)
+ assert len(courseParticipantPreview) == 4
+
+
+
+
diff --git a/tests/code/test_participants.py b/tests/code/test_participants.py
index 0d8189c2f..90c032b2b 100644
--- a/tests/code/test_participants.py
+++ b/tests/code/test_participants.py
@@ -196,15 +196,11 @@ def test_trainedParticipants():
attendedPreq = trainedParticipants(3, currentTerm)
assert attendedPreq == [khatts]
- currentTerm = Term.get_by_id(2) # Spring A 2021
+ currentTerm = Term.get_by_id(2) # Spring 2021
attendedPreq = trainedParticipants(3, currentTerm)
assert attendedPreq == [khatts]
- currentTerm = Term.get_by_id(3) # Spring B 2021
- attendedPreq = trainedParticipants(3, currentTerm)
- assert attendedPreq == [khatts]
-
- currentTerm = Term.get_by_id(4) # Summer 2021
+ currentTerm = Term.get_by_id(3) # Summer 2021
attendedPreq = trainedParticipants(3, currentTerm)
assert attendedPreq == [khatts]
diff --git a/tests/code/test_serviceLearningCoursesData.py b/tests/code/test_serviceLearningCoursesData.py
index b142a6e53..1b14ca8be 100644
--- a/tests/code/test_serviceLearningCoursesData.py
+++ b/tests/code/test_serviceLearningCoursesData.py
@@ -1,7 +1,6 @@
import pytest
-from flask import Flask, g
-from datetime import datetime
+from flask import g
from peewee import DoesNotExist
from app import app
@@ -9,7 +8,6 @@
from app.models.term import Term
from app.models.user import User
from app.models.course import Course
-from app.models.course import CourseStatus
from app.models.courseParticipant import CourseParticipant
from app.models.courseInstructor import CourseInstructor
from app.models.courseQuestion import CourseQuestion
@@ -26,7 +24,7 @@ def test_getServiceLearningCoursesData():
assert 'Brian Ramsay' in courseDict[2]['faculty']
assert ['Brian Ramsay', 'Zach Neill'] == courseDict[2]['faculty']
assert "Submitted" == courseDict[2]['status']
- assert 'Spring A 2021' in courseDict[2]['term'].description
+ assert 'Spring 2021' in courseDict[2]['term'].description
assert "Scott Heggen" == courseDict[2]['creator']
courseDict = getServiceLearningCoursesData('heggens')
@@ -42,7 +40,7 @@ def test_getServiceLearningCoursesData():
assert 'Scott Heggen' not in courseDict[4]['faculty']
assert ['Brian Ramsay', 'Ala Qasem'] == courseDict[4]['faculty']
assert "In Progress" == courseDict[4]['status']
- assert 'Spring A 2021' in courseDict[4]['term'].description
+ assert 'Spring 2021' in courseDict[4]['term'].description
assert "Scott Heggen" == courseDict[4]['creator']
@pytest.mark.integration
diff --git a/tests/code/test_term.py b/tests/code/test_term.py
new file mode 100644
index 000000000..8b9a8863b
--- /dev/null
+++ b/tests/code/test_term.py
@@ -0,0 +1,109 @@
+import pytest
+from app.models import mainDB
+from app.models.term import Term
+from app.logic.utils import selectSurroundingTerms
+from app.logic.term import addNextTerm, changeCurrentTerm, addPastTerm
+
+@pytest.mark.integration
+def test_selectSurroundingTerms():
+ listOfTerms = selectSurroundingTerms(Term.get_by_id(3))
+ assert 8 == len(listOfTerms)
+
+ listOfTerms = selectSurroundingTerms(Term.get_by_id(3), prevTerms=0)
+ assert [3,4,5,6,7,8] == [t.id for t in listOfTerms]
+
+ listOfTerms = selectSurroundingTerms(Term.get_by_id(3), prevTerms=1)
+ assert [2,3,4,5,6,7,8] == [t.id for t in listOfTerms]
+
+ listOfTerms = selectSurroundingTerms(Term.get_by_id(3), prevTerms=-1)
+ assert [4,5,6,7,8] == [t.id for t in listOfTerms]
+
+def test_changeCurrentTerm():
+ # test via g.current_term
+ oldTerm = g.current_term
+ changeCurrentTerm(2)
+ assert g.current_term == 2
+ assert not oldTerm
+
+ # test via isCurrentTerm
+ oldTerm2 = g.current_term
+ newTerm = changeCurrentTerm(1)
+ assert newTerm.isCurrentTerm
+ assert not oldTerm2 == g.current_term
+ assert not oldTerm2.isCurrentTerm
+
+ # reset data back to before test
+ changeCurrentTerm(oldTerm)
+
+def test_invalidTermInputs():
+ with pytest.raises(DoesNotExist):
+ changeCurrentTerm(100)
+ with pytest.raises(DoesNotExist):
+ changeCurrentTerm("womp")
+
+@pytest.mark.integration
+def test_addNextTerm():
+ with mainDB.atomic() as transaction:
+ testTerm = Term.create(description="Summer 2022",year=2022, academicYear= "2021-2022", isSummer=True, isCurrentTerm=True, termOrder = Term.convertDescriptionToTermOrder("Summer 2022"))
+ testTerm.save()
+
+ addNextTerm()
+
+ terms = list(Term.select().order_by(Term.id))
+ newTerm = terms[-1]
+ assert newTerm.description == "Summer 2023"
+ assert newTerm.year == 2023
+ assert newTerm.academicYear == "2022-2023"
+ assert newTerm.isSummer
+ assert not newTerm.isCurrentTerm
+
+ transaction.rollback()
+
+ with mainDB.atomic() as transaction:
+ testTerm = Term.create(description="Fall 2029",year=2029, academicYear= "2029-2030", isSummer=False,isCurrentTerm=False, termOrder = Term.convertDescriptionToTermOrder("Fall 2029"))
+ testTerm.save()
+
+ newTerm = addNextTerm()
+ assert newTerm.description == "Spring 2030"
+ assert newTerm.year == 2030
+ assert newTerm.academicYear == "2029-2030"
+ assert not newTerm.isSummer
+ assert not newTerm.isCurrentTerm
+
+ transaction.rollback()
+
+ with mainDB.atomic() as transaction:
+ testTerm = Term.create(description="Spring 2024",year=2022, academicYear= "2023-2024", isSummer=False,isCurrentTerm=False, termOrder = Term.convertDescriptionToTermOrder("Spring 2024") )
+ testTerm.save()
+
+ newTerm = addNextTerm()
+ assert newTerm.description == "Summer 2024"
+ assert newTerm.year == 2024
+ assert newTerm.academicYear == "2023-2024"
+ assert newTerm.isSummer
+ assert not newTerm.isCurrentTerm
+
+ transaction.rollback()
+
+@pytest.mark.integration
+def test_addPastTerm():
+ with mainDB.atomic() as transaction:
+
+ assert Term.get_or_none(description = 'Fall 2019') == None
+ addPastTerm('Fall 2019')
+ testTerm = Term.get_or_none(description = 'Fall 2019')
+ assert testTerm.academicYear == '2019-2020'
+ assert testTerm.year == 2019
+ assert not testTerm.isSummer
+
+ transaction.rollback()
+
+ with mainDB.atomic() as transaction:
+ assert Term.get_or_none(description = 'Summer 1999') == None
+ addPastTerm('Summer 1999')
+ testTerm = Term.get_or_none(description = 'Summer 1999')
+ assert testTerm.academicYear == '1998-1999'
+ assert testTerm.year == 1999
+ assert testTerm.isSummer
+
+ transaction.rollback()
\ No newline at end of file
diff --git a/tests/code/test_utils.py b/tests/code/test_utils.py
index e442e1868..4b96bfd35 100644
--- a/tests/code/test_utils.py
+++ b/tests/code/test_utils.py
@@ -1,95 +1,8 @@
import pytest
-
from app.models import mainDB
-from app.models.user import User
from app.models.term import Term
-from app.logic.utils import selectSurroundingTerms
-from app.logic.userManagement import addCeltsAdmin, removeCeltsAdmin,addCeltsStudentStaff, removeCeltsStudentStaff, changeCurrentTerm, addNextTerm
-
-
-@pytest.mark.integration
-def test_selectSurroundingTerms():
- listOfTerms = selectSurroundingTerms(Term.get_by_id(3))
- assert 9 == len(listOfTerms)
-
- listOfTerms = selectSurroundingTerms(Term.get_by_id(3), prevTerms=0)
- assert [3,4,5,6,7,8,9] == [t.id for t in listOfTerms]
-
- listOfTerms = selectSurroundingTerms(Term.get_by_id(3), prevTerms=1)
- assert [2,3,4,5,6,7,8,9] == [t.id for t in listOfTerms]
-
- listOfTerms = selectSurroundingTerms(Term.get_by_id(3), prevTerms=-1)
- assert [4,5,6,7,8,9] == [t.id for t in listOfTerms]
-
-def test_changeCurrentTerm():
- # test via g.current_term
- oldTerm = g.current_term
- changeCurrentTerm(2)
- assert g.current_term == 2
- assert not oldTerm
-
- # test via isCurrentTerm
- oldTerm2 = g.current_term
- newTerm = changeCurrentTerm(1)
- assert newTerm.isCurrentTerm
- assert not oldTerm2 == g.current_term
- assert not oldTerm2.isCurrentTerm
-
- # reset data back to before test
- changeCurrentTerm(oldTerm)
-
-def test_invalidTermInputs():
- with pytest.raises(DoesNotExist):
- changeCurrentTerm(100)
- with pytest.raises(DoesNotExist):
- changeCurrentTerm("womp")
-
-@pytest.mark.integration
-def test_addNextTerm():
- with mainDB.atomic() as transaction:
- testTerm = Term.create(description="Summer 2022",year=2022, academicYear= "2021-2022", isSummer=True,isCurrentTerm=True)
- testTerm.save()
-
- addNextTerm()
-
- # for the first test, make sure we're using the db properly
- terms = list(Term.select().order_by(Term.id))
- newTerm = terms[-1]
- assert newTerm.description == "Fall 2022"
- assert newTerm.year == 2022
- assert newTerm.academicYear == "2022-2023"
- assert not newTerm.isSummer
- assert not newTerm.isCurrentTerm
-
- transaction.rollback()
-
-
- with mainDB.atomic() as transaction:
- testTerm = Term.create(description="Fall 2029",year=2029, academicYear= "2029-2030", isSummer=False,isCurrentTerm=False)
- testTerm.save()
-
- newTerm = addNextTerm()
- assert newTerm.description == "Spring 2030"
- assert newTerm.year == 2030
- assert newTerm.academicYear == "2029-2030"
- assert not newTerm.isSummer
- assert not newTerm.isCurrentTerm
-
- transaction.rollback()
- with mainDB.atomic() as transaction:
- testTerm = Term.create(description="Spring 2022",year=2022, academicYear= "2021-2022", isSummer=False,isCurrentTerm=False)
- testTerm.save()
-
- newTerm = addNextTerm()
- assert newTerm.description == "Summer 2022"
- assert newTerm.year == 2022
- assert newTerm.academicYear == "2021-2022"
- assert newTerm.isSummer
- assert not newTerm.isCurrentTerm
-
- transaction.rollback()
@pytest.mark.integration
def test_getStartofCurrentAcademicYear():
@@ -110,10 +23,9 @@ def test_getStartofCurrentAcademicYear():
# Case3: current term is Summer 2021
currentTerm = Term.get_by_id(4)
fallTerm = currentTerm.academicYearStartingTerm
-
- assert fallTerm.year == 2020
- assert fallTerm.description == "Fall 2020"
- assert fallTerm.academicYear == "2020-2021"
+ assert fallTerm.year == 2021
+ assert fallTerm.description == "Fall 2021"
+ assert fallTerm.academicYear == "2021-2022"
# Case4: current term has no earlier term, just return itself
newTerm = Term.create(description="Summer 2020", year=2020, academicYear="2019-2020",isSummer=1,isCurrentTerm=0)
diff --git a/tests/files/parseUpload_InvalidTest.xlsx b/tests/files/parseUpload_InvalidTest.xlsx
new file mode 100644
index 000000000..2fda5ba48
Binary files /dev/null and b/tests/files/parseUpload_InvalidTest.xlsx differ
diff --git a/tests/files/parseUpload_ValidTest.xlsx b/tests/files/parseUpload_ValidTest.xlsx
new file mode 100644
index 000000000..8e3c25563
Binary files /dev/null and b/tests/files/parseUpload_ValidTest.xlsx differ