diff --git a/app/controllers/admin/routes.py b/app/controllers/admin/routes.py index 8d24ffdf6..b9032991e 100644 --- a/app/controllers/admin/routes.py +++ b/app/controllers/admin/routes.py @@ -323,7 +323,6 @@ def eventDisplay(eventId): for year, cohort in rawBonnerCohorts.items(): if cohort: bonnerCohorts[year] = cohort - invitedCohorts = list(EventCohort.select().where( EventCohort.event_id == eventId, )) diff --git a/app/controllers/main/routes.py b/app/controllers/main/routes.py index f9d17d1c4..45b9a2589 100644 --- a/app/controllers/main/routes.py +++ b/app/controllers/main/routes.py @@ -221,9 +221,7 @@ def viewUsersProfile(username): "onTranscript": onTranscript}), profileNotes = ProfileNote.select().where(ProfileNote.user == volunteer) - bonnerRequirements = getCertRequirementsWithCompletion(certification=Certification.BONNER, username=volunteer) - managersProgramDict = getManagerProgramDict(g.current_user) managersList = [id[1] for id in managersProgramDict.items()] totalSustainedEngagements = getEngagementTotal(getCommunityEngagementByTerm(volunteer)) diff --git a/app/logic/certification.py b/app/logic/certification.py index 70c3beb03..8562e09b5 100644 --- a/app/logic/certification.py +++ b/app/logic/certification.py @@ -1,18 +1,95 @@ -from peewee import JOIN, DoesNotExist, Case - +from peewee import JOIN, fn, DoesNotExist, Case +from flask import g +from app.models.event import Event +from app.models.term import Term from app.models.certification import Certification from app.models.certificationRequirement import CertificationRequirement from app.models.requirementMatch import RequirementMatch from app.models.eventParticipant import EventParticipant +from app.models.user import User +import math +def termsAttended(certification, username): + ''' + Retrieve terms attended by a user for certification and filter them based on frequency of a term + ''' + attendedTerms = [] + attendance = (RequirementMatch.select() + .join(EventParticipant, JOIN.LEFT_OUTER, on=(RequirementMatch.event == EventParticipant.event)) + .where(RequirementMatch.requirement_id == certification) + .where(EventParticipant.user == username)) + for termRecord in range(len(attendance)): + if not attendance[termRecord].event.term.isSummer: + attendedTerms.append(attendance[termRecord].event.term.description) + totalTerms = termsInTotal(username) + attendedTerms = {term for term in attendedTerms if term in totalTerms} + return attendedTerms + + +def termsInTotal(username): + ''' + The function returns all non-summer academic terms a student should have, based on their class level where it finds + the start term and populate from it with Fall-start alignment and special handling for NULL/Non-degree class level + ''' + currentTerm = g.current_term + currentDesc = currentTerm.description + user = User.select().where(User.username == username).get() + if currentTerm.isSummer and user.rawClassLevel == "Freshman": + currentDesc = f"Fall {currentTerm.year}" + elif currentTerm.isSummer: + currentDesc = f"Spring {currentTerm.year}" + classLevel = ["Freshman", "Sophomore", "Junior", "Senior"] + totalTerms = [] + for level, name in enumerate(classLevel): + if user.rawClassLevel == name: + totalTermsCount = (level + 1) * 2 + if currentDesc.startswith("Fall"): + totalTermsCount -= 1 + if currentDesc.startswith("Spring"): + startYear = currentTerm.year - level - 1 + else: + startYear = currentTerm.year - level + for k in range(totalTermsCount): + if k % 2 == 0: + season = "Fall" + year = startYear + (k // 2) + else: + season = "Spring" + year = startYear + (k // 2) + 1 + totalTerms.append(f"{season} {year}") + break + + if user.rawClassLevel is None or user.rawClassLevel in ["NULL", "Graduating", "Non-Degree"]: + totalTermsCount = 8 + currentYear = currentTerm.year + currentSeason = "Fall" if "Fall" in currentDesc else "Spring" + for a in range(totalTermsCount): + totalTerms.append(f"{currentSeason} {currentYear}") + if currentSeason == "Fall": + currentSeason = "Spring" + else: + currentSeason = "Fall" + currentYear -= 1 + list.reverse(totalTerms) + return totalTerms + +def termsMissed(certification, username): + ''' + Calculate how many certification-eligible terms a student has missed based on their class level + and attendance record. + ''' + totalTerms = termsInTotal(username) + attendedTerms = termsAttended(certification, username) + missedTerms = [term for term in totalTerms if term not in attendedTerms] + return missedTerms + def getCertRequirementsWithCompletion(*, certification, username): """ - Function to differentiate between simple requirements and requirements completion checking. - See: `getCertRequirements` + Differentiate between simple requirements and requirements completion checking. """ - return getCertRequirements(certification, username) + return getCertRequirements(certification, username, reqCheck=True) -def getCertRequirements(certification=None, username=None): +def getCertRequirements(certification=None, username=None, reqCheck=False): """ Return the requirements for all certifications, or for one if requested. @@ -28,7 +105,6 @@ def getCertRequirements(certification=None, username=None): reqList = (Certification.select(Certification, CertificationRequirement) .join(CertificationRequirement, JOIN.LEFT_OUTER, attr="requirement") .order_by(Certification.id, CertificationRequirement.order.asc(nulls="LAST"))) - if certification: if username: # I don't know how to add something to a select, so we have to recreate the whole query :( @@ -37,32 +113,63 @@ def getCertRequirements(certification=None, username=None): .select(Certification, CertificationRequirement, completedCase.alias("completed")) .join(CertificationRequirement, JOIN.LEFT_OUTER, attr="requirement") .join(RequirementMatch, JOIN.LEFT_OUTER) - .join(EventParticipant, JOIN.LEFT_OUTER, on=(RequirementMatch.event == EventParticipant.event)) - .where(EventParticipant.user.is_null(True) | (EventParticipant.user == username)) + .join(EventParticipant, JOIN.LEFT_OUTER, on=(RequirementMatch.event == EventParticipant.event) & (EventParticipant.user == username)) .order_by(Certification.id, CertificationRequirement.order.asc(nulls="LAST"))) - # we have to add the is not null check so that `cert.requirement` always exists reqList = reqList.where(Certification.id == certification, CertificationRequirement.id.is_null(False)) - reqList = reqList.distinct() - - certs = [] + certificationList = [] for cert in reqList: if username: cert.requirement.completed = bool(cert.__dict__['completed']) - certs.append(cert.requirement) - return certs - - #return [cert.requirement for cert in reqList] - - certs = {} + # this is to get the calculation when it comes to events with term, twice, annual as their frequency + cert.requirement.attendedTerms = len(termsAttended(cert.requirement.id, username)) + cert.requirement.attendedDescriptions = termsAttended(cert.requirement.id, username) + if cert.requirement.frequency == "term": + cert.requirement.missedTerms = len(termsMissed(cert.requirement.id, username)) + cert.requirement.missedDescriptions = termsMissed(cert.requirement.id, username) + cert.requirement.totalTerms = len(termsInTotal(username)) + elif cert.requirement.frequency == "annual": + totalTerms = len(termsInTotal(username)) + cert.requirement.attendedAnnual = len(termsAttended(cert.requirement.id, username)) + cert.requirement.totalAnnual = int(math.floor(totalTerms/2+0.5)) if totalTerms % 2 == 1 else totalTerms/2 + elif cert.requirement.frequency == "once" and cert.requirement.completed: + term_record = (RequirementMatch + .select(RequirementMatch, Event, Term) + .join(Event) + .join(Term) + .where(RequirementMatch.requirement == cert.requirement.id) + .order_by(Term.year.desc()) # latest term first + .first() + ) + cert.requirement.attendedTerm = term_record.event.term.description + certificationList.append(cert.requirement) + + # the .distinct() doesn't work efficiently, so we have to manually go through the list and removed duplicates that exist + validCertification = set() + certificationIndex = 0 + uniqueCertification = [] + + for cert in certificationList: + req = certificationList[certificationIndex] + if req not in validCertification: + validCertification.add(req) + uniqueCertification.append(req) + # Override incomplete requirement when a completed 'once' requirement is found when removing duplicates + elif reqCheck and req.frequency == "once" and req.completed: + for i in range(len(uniqueCertification)): + if uniqueCertification[i].id == req.id and not uniqueCertification[i].completed: + uniqueCertification[i] = req + validCertification.add(req) + certificationIndex += 1 + certificationList = uniqueCertification + return certificationList + certificationDict = {} for cert in reqList: - if cert.id not in certs.keys(): - certs[cert.id] = {"data": cert, "requirements": []} - + if cert.id not in certificationDict.keys(): + certificationDict[cert.id] = {"data": cert, "requirements": []} if getattr(cert, 'requirement', None): - certs[cert.id]["requirements"].append(cert.requirement) - - return certs + certificationDict[cert.id]["requirements"].append(cert.requirement) + return certificationDict def updateCertRequirements(certId, newRequirements): """ diff --git a/app/logic/volunteerSpreadsheet.py b/app/logic/volunteerSpreadsheet.py index 6a03ca6ac..f75d58fff 100644 --- a/app/logic/volunteerSpreadsheet.py +++ b/app/logic/volunteerSpreadsheet.py @@ -195,7 +195,7 @@ def getRetentionRate(academicYear): def termParticipation(term): base = getBaseQuery(term.academicYear) - + participationQuery = (base.select(Event.program, EventParticipant.user_id.alias('participant'), Program.programName.alias("programName")) .where(Event.term == term) .order_by(EventParticipant.user)) diff --git a/app/static/js/userProfile.js b/app/static/js/userProfile.js index 7fe6a2c8b..51d5344fc 100644 --- a/app/static/js/userProfile.js +++ b/app/static/js/userProfile.js @@ -1,6 +1,6 @@ $(document).ready(function(){ - $("#checkDietRestriction").on("change", function() { + $("#checkDietRestriction").on("change", function() { let norestrict = $(this).is(':checked'); if (norestrict) { $("#dietContainer").hide(); @@ -35,7 +35,6 @@ $(document).ready(function(){ }); }) - $("#phoneInput").inputmask('(999)-999-9999'); $(".notifyInput").click(function updateInterest(){ var programID = $(this).data("programid"); var username = $(this).data('username'); @@ -216,6 +215,8 @@ $(document).ready(function(){ } }); }); + }); + $(".deleteNoteButton").click(function() { let username = $(this).data('username') @@ -307,17 +308,27 @@ $(document).ready(function(){ }) }); - // Popover functionality - var requiredTraining = $(".trainingPopover"); - requiredTraining.popover({ - trigger: "hover", - sanitize: false, - html: true, - content: function() { - return $(this).attr('data-content'); - } + $(function () { + $('.trainingPopover').each(function () { + new bootstrap.Popover(this, { + trigger: 'hover focus', + html: true, + sanitize: false, + placement: 'right', + }); + }); }); - + $(function () { + $('.bonnerCheckmark').each(function () { + new bootstrap.Popover(this, { + trigger: 'hover focus', + html: true, + sanitize: false, + placement: 'right', + }); + }); + }); + setupPhoneNumber("#updatePhone", "#phoneInput") // Dietary Restrictions @@ -355,8 +366,10 @@ $(document).ready(function(){ typingTimer = setTimeout(saveDiet, saveInterval); }); }); - -}); // end document.ready() + const bonnerStudent = $("#bonnerStudent").data('username') + if (bonnerStudent === "False"){ + $("#bonnerStudent").prop("hidden", true) + }; // end document.ready() // Update program manager status function updateManagers(el, volunteerUsername ) { @@ -387,3 +400,4 @@ function updateManagers(el, volunteerUsername ) { } }) } + diff --git a/app/templates/admin/bonnerManagement.html b/app/templates/admin/bonnerManagement.html index ebe02bf95..54c30eddd 100644 --- a/app/templates/admin/bonnerManagement.html +++ b/app/templates/admin/bonnerManagement.html @@ -148,6 +148,7 @@

diff --git a/app/templates/main/userProfile.html b/app/templates/main/userProfile.html index 6fee84932..a34e50252 100644 --- a/app/templates/main/userProfile.html +++ b/app/templates/main/userProfile.html @@ -5,6 +5,7 @@ {{super()}} + {% endblock %} {% block styles %} @@ -26,7 +27,9 @@

{{volunteer.firstName}} {{volunteer.lastName}}

{% if volunteer.major -%}
{{volunteer.major}}
{% endif %} -
{{volunteer.processedClassLevel}}
+ {% if volunteer.classLevel %} +
{{volunteer.classLevel}}
+ {% endif %} {% if volunteer.cpoNumber %}
{{volunteer.cpoNumber}} @@ -451,14 +454,15 @@

{% set canViewBonner = (g.current_user.isCeltsAdmin or g.current_user == volunteer) %} {% if volunteer.isBonnerScholar and canViewBonner %} -
-

- {% set focus = "open" if visibleAccordion == "bonner" else "collapsed" %} - -

- {% set show = "show" if visibleAccordion == "bonner" else "" %} -
-
+
+
+

+ {% set focus = "open" if visibleAccordion == "bonner" else "collapsed" %} + +

+ {% set show = "show" if visibleAccordion == "bonner" else "" %} +
+
{# Bonner Events #} @@ -498,13 +502,60 @@
Notes
Requirement Progress
    {% for req in bonnerRequirements %} -
  • {{req.name}} - {% if req.completed %} - +
  • + + {{req.name}} + {% if req.frequency == "term"%} + {% set attendedCount = req.attendedTerms %} + ({{attendedCount}}/{{req.totalTerms}}) + {% elif req.frequency == "twice" %} + ({{req.attendedTerms}}/2) + {% elif req.completed == True and req.frequency == "once" %} + (1/1) + {% elif req.completed == False and req.frequency == "once" %} + (0/1) + {% elif req.frequency == "annual" %} + ({{req.attendedAnnual}}/{{req.totalAnnual}}) + {% endif %} + + {% set popover_text = "" %} + {% if req.frequency == "term" %} + {% if req.attendedDescriptions|length > 0 or req.missedDescriptions|length > 0 %} + {% if req.attendedDescriptions|length > 0 %} + {% set popover_text = popover_text ~ "Attended:
    " ~ (req.attendedDescriptions | join(', ')) %} + {% else %} + {% set popover_text = popover_text ~ "Attended: None
    " %} + {% endif %} + {% if req.missedDescriptions|length > 0 %} + {% set popover_text = popover_text ~ "
    Missed:
    " ~ (req.missedDescriptions | join(', ')) %} + {% else %} + {% set popover_text = popover_text ~ "
    Missed: None" %} + {% endif %} + {% endif %} + {% elif req.frequency == "once" and req.completed %} + {% set popover_text = "Attended: " ~ (req.attendedTerm) %} + {% elif req.frequency == "twice"%} + {% set popover_text = "Attended: " ~ (req.attendedDescriptions | join(', ')) %} + {% elif req.frequency == "annual" %} + {% if req.attendedDescriptions|length > 0 %} + {% set popover_text = "Attended:
    " ~ (req.attendedDescriptions | join(', ')) %} + {% endif %} {% else %} - + {% set popover_text = "You haven’t attended any event(s) yet." %} {% endif %} + + View +
  • +
    {% endfor %}
@@ -512,6 +563,7 @@
Requirement Progress
+
{% endif %} diff --git a/tests/code/test_certification.py b/tests/code/test_certification.py index c3f5de185..1f266d3cc 100644 --- a/tests/code/test_certification.py +++ b/tests/code/test_certification.py @@ -1,47 +1,156 @@ import pytest +from flask import g from peewee import DoesNotExist - +from app import app from app.models import mainDB from app.models.event import Event +from app.models.term import Term +from app.models.user import User from app.models.certification import Certification from app.models.certificationRequirement import CertificationRequirement from app.models.requirementMatch import RequirementMatch from app.models.eventParticipant import EventParticipant -from app.logic.certification import getCertRequirements, updateCertRequirements, updateCertRequirementForEvent +from app.logic.certification import getCertRequirements, updateCertRequirements, updateCertRequirementForEvent, termsAttended, termsMissed, termsInTotal from app.logic.certification import getCertRequirementsWithCompletion +from app.logic.loginManager import getCurrentTerm + +@pytest.mark.integration +def test_termsAttended(): + + with mainDB.atomic() as transaction: + # created the database and added the test data to test what terms are return from attendedTerms() + with app.app_context(): + Term.update(isCurrentTerm=False).execute() + Term.create(id = 1000, description = "Spring 2020", year = 2020, academicYear = 2019-2020, isSummer = False, isCurrentTerm = True, termOrder = 2020-1) + Term.create(id = 1001, description = "Fall 2019", year = 2019, academicYear = 2019-2020, isSummer = False, isCurrentTerm = False, termOrder = 2019-3) + g.current_term = getCurrentTerm() + Event.create(id = 1400, term_id = 1000, name = "Event 1", description = "Spring 2020", program_id = 5) + Event.create(id = 1401, term_id = 1001, name = "Event 2", description = "Spring 2019", program_id = 5) + User.create(username='zawn', rawClassLevel='Senior') + CertificationRequirement.create(id = 400, certification_id = 1, name = "CPR Training", frequency = "term", required = True) + RequirementMatch.create(event_id=1400, requirement_id=400) + EventParticipant.create(event_id=1400, user_id='zawn') + RequirementMatch.create(event_id=1401, requirement_id=400) + EventParticipant.create(event_id=1401, user_id='zawn') + attendedTermsNum = len(termsAttended(certification=400, username='zawn')) + assert attendedTermsNum == 2 + transaction.rollback() + +@pytest.mark.integration +def test_termsMissed(): + with mainDB.atomic() as transaction: + with app.app_context(): + Term.update(isCurrentTerm=False).execute() + Term.create(id = 1000, description = "Fall 2019", year = 2019, academicYear = 2019-2020, isSummer = False, isCurrentTerm = True, termOrder = 2019-3) + g.current_term = getCurrentTerm() + Event.create(id = 1400, term_id = 1000, name = "Event 1", description = "Fall 2019", program_id = 5) + User.create(username='zawn', rawClassLevel='Senior') + CertificationRequirement.create(id = 400, certification_id = 1, name = "CPR Training", frequency = "term", required = True) + RequirementMatch.create(event_id=1400, requirement_id=400) + EventParticipant.create(event_id=1400, user_id='zawn') + missedTerms = termsMissed(certification=400, username='zawn') + assert missedTerms == ['Fall 2016', 'Spring 2017', 'Fall 2017', 'Spring 2018', 'Fall 2018', 'Spring 2019'] + transaction.rollback() + + + with mainDB.atomic() as transaction: + with app.app_context(): + Term.update(isCurrentTerm=False).execute() + Term.create(id = 1000, description = "Summer 2022", year = 2022, academicYear = 2022-2023, isSummer = True, isCurrentTerm = True, termOrder = 2022-2) + g.current_term = getCurrentTerm() + Event.create(id = 1400, term_id = 1000, name = "Event 1", description = "Summer 2022", program_id = 5) + User.create(username='zawn', rawClassLevel='Freshman') + CertificationRequirement.create(id = 400, certification_id = 1, name = "CPR Training", frequency = "term", required = True) + missedTerms = termsMissed(certification=400, username='zawn') + assert missedTerms == ["Fall 2022"] + transaction.rollback() + + with mainDB.atomic() as transaction: + with app.app_context(): + Term.update(isCurrentTerm=False).execute() + Term.create(id = 1001, description = "Spring 2022", year = 2022, academicYear = 2021-2022, isSummer = False, isCurrentTerm = True, termOrder = 2022-1) + Term.create(id = 1000, description = "Spring 2021", year = 2021, academicYear = 2020-2021, isSummer = False, isCurrentTerm = False, termOrder = 2021-1) + g.current_term = getCurrentTerm() + Event.create(id = 1400, term_id = 1000, name = "Event 1", description = "Spring 2021", program_id = 5) + User.create(username='zawn', rawClassLevel='Junior') + CertificationRequirement.create(id = 400, certification_id = 1, name = "CPR Training", frequency = "term", required = True) + RequirementMatch.create(event_id=1400, requirement_id=400) + EventParticipant.create(event_id=1400, user_id='zawn') + missedTerms = termsMissed(certification=400, username='zawn') + assert missedTerms == ["Fall 2019", "Spring 2020", "Fall 2020", "Fall 2021", "Spring 2022"] + transaction.rollback() + +@pytest.mark.integration +def test_termsInTotal(): + with mainDB.atomic() as transaction: + with app.app_context(): + Term.update(isCurrentTerm=False).execute() + Term.create(id = 1000, description = "Spring 2021", year = 2021, academicYear = 2020-2021, isSummer = False, isCurrentTerm = True, termOrder = 2021-1) + g.current_term = getCurrentTerm() + User.create(username='zawn', rawClassLevel='Senior') + totalTerms = termsInTotal(username='zawn') + assert totalTerms == ["Fall 2017", "Spring 2018", "Fall 2018", "Spring 2019", "Fall 2019", "Spring 2020", "Fall 2020", "Spring 2021"] + transaction.rollback() + + with mainDB.atomic() as transaction: + with app.app_context(): + Term.update(isCurrentTerm=False).execute() + Term.create(id = 1000, description = "Spring 2020", year = 2020, academicYear = 2019-2020, isSummer = False, isCurrentTerm = True, termOrder = 2020-1) + g.current_term = getCurrentTerm() + User.create(username='zawn', rawClassLevel='Graduating') + totalTerms = termsInTotal(username='zawn') + assert totalTerms == ["Fall 2016", "Spring 2017", "Fall 2017", "Spring 2018", "Fall 2018", "Spring 2019", "Fall 2019", "Spring 2020"] + transaction.rollback() + + with mainDB.atomic() as transaction: + with app.app_context(): + Term.update(isCurrentTerm=False).execute() + Term.create(id = 1000, description = "Fall 2018", year = 2018, academicYear = 2017-2018, isSummer = False, isCurrentTerm = True, termOrder = 2018-3) + g.current_term = getCurrentTerm() + User.create(username='zawn', rawClassLevel='Sophomore') + totalTerms = termsInTotal(username='zawn') + assert totalTerms == ["Fall 2017", "Spring 2018", "Fall 2018"] + transaction.rollback() + @pytest.mark.integration def test_getCertRequirements(): - allRequirements = getCertRequirements() + with mainDB.atomic() as transaction: + allRequirements = getCertRequirements() - certNames = ["Bonner", "CCE Minor", "CPR", "Confidentiality", "I9"] - assert certNames == [cert["data"].name for (id, cert) in allRequirements.items()] - cpr = allRequirements[3]['requirements'] - assert ["Volunteer Training", "CPR Training"] == [r.name for r in cpr] + certNames = ["Bonner", "CCE Minor", "CPR", "Confidentiality", "I9"] + assert certNames == [cert["data"].name for (id, cert) in allRequirements.items()] + cpr = allRequirements[3]['requirements'] + assert ["Volunteer Training", "CPR Training"] == [r.name for r in cpr] + + bonner = getCertRequirements(certification=Certification.BONNER) + assert len(bonner) == 9 + + noRequirements = getCertRequirements(certification=1111) + assert len(noRequirements) == 0 + transaction.rollback() - bonner = getCertRequirements(certification=Certification.BONNER) - assert len(bonner) == 9 - noRequirements = getCertRequirements(certification=1111) - assert len(noRequirements) == 0 @pytest.mark.integration def test_getCertRequirementsWithCompletion(): with mainDB.atomic() as transaction: - # add two matches for the same requirement to make sure we only return one row per requirement - RequirementMatch.create(event_id=14, requirement_id=10) - EventParticipant.create(event_id=14, user_id='ramsayb2') - RequirementMatch.create(event_id=13, requirement_id=10) - EventParticipant.create(event_id=13, user_id='ramsayb2') - cprcert = 3 - - cprreqs = getCertRequirementsWithCompletion(certification=cprcert, username='ramsayb2') - assert len(cprreqs) == 2 - assert not cprreqs[0].completed, "The first event should not be completed" - assert cprreqs[1].completed, "The second event should be completed" - + with app.app_context(): + # # add two matches for the same requirement to make sure we only return one row per requirement + Term.update(isCurrentTerm=False).execute() + Term.create(id=1000, description="Spring 2020", year=2020, academicYear=2019-2020, isSummer=False, isCurrentTerm=True, termOrder=2020-1) + g.current_term = getCurrentTerm() + RequirementMatch.create(event_id=14, requirement_id=10) + EventParticipant.create(event_id=14, user_id='ramsayb2') + RequirementMatch.create(event_id=13, requirement_id=10) + EventParticipant.create(event_id=13, user_id='ramsayb2') + cprcert = 3 + cprreqs = getCertRequirementsWithCompletion(certification=cprcert, username='ramsayb2') + assert len(cprreqs) == 2 + assert not cprreqs[0].completed, "The first event should not be completed" + assert cprreqs[1].completed, "The second event should be completed" transaction.rollback() @pytest.mark.integration @@ -96,8 +205,9 @@ def test_updateCertRequirements(): ] returnedIds = updateCertRequirements(otherId, newRequirements) selectedIds = getCertRequirements(certification=otherId) + fetchedIds = list(CertificationRequirement.select().where(CertificationRequirement.certification == otherId).order_by(CertificationRequirement.order)) - assert selectedIds == list(CertificationRequirement.select().where(CertificationRequirement.certification == otherId).order_by(CertificationRequirement.order)) + assert selectedIds == fetchedIds assert returnedIds == selectedIds assert returnedIds[1].name == "CPR 2" assert returnedIds[1].frequency == "once" diff --git a/tests/code/test_serviceLearningCourses.py b/tests/code/test_serviceLearningCourses.py index 6c82fd878..e9157734e 100644 --- a/tests/code/test_serviceLearningCourses.py +++ b/tests/code/test_serviceLearningCourses.py @@ -126,8 +126,8 @@ def test_courseManagement(): assert importedCourse in getImportedCourses(termId) assert unapprovedList[courseindex].instructors == " Brian Ramsay, Zach Neill" - transaction.rollback() + @pytest.mark.integration def test_withdrawProposal(): '''creates a test course with all foreign key fields. tests if they can