Problem Statement
File: esp/esp/program/modules/tests/ajaxschedulingmodule.py — Line 192
testChangeLogUnscheduledClasses currently only asserts that the changelog contains exactly one entry after unscheduling a class, but does not verify the content of that entry — specifically that it correctly records an unschedule action (i.e., room_name == "" and timeslots == []).
The AJAXChangeLogEntry.toDict() method in module_ext.py (lines 331–347) already exposes these fields in the JSON response. A future bug in ajax_schedule_deletereg — for example, accidentally logging a schedule action instead of an unschedule action — would not be caught by the current test.
Proposed Solution
Extend the test with 4 additional assertions to validate the changelog entry's content, not just its presence.
Before:
changelog_response = self.client.get(self.changelog_url, {'last_fetched_index': 1})
changelog = json.loads(changelog_response.content)["changelog"]
self.assertTrue(len(changelog) == 1, "Change log did not contain the unscheduled class: " + str(changelog))
#TODO: more detailed testing here
After:
changelog_response = self.client.get(self.changelog_url, {'last_fetched_index': 1})
changelog = json.loads(changelog_response.content)["changelog"]
self.assertTrue(len(changelog) == 1, "Change log did not contain the unscheduled class: " + str(changelog))
entry = changelog[0]
self.assertEqual(entry['id'], section.id, "Changelog entry has wrong class section ID")
self.assertTrue(entry['is_scheduling'], "Changelog entry should be a scheduling entry")
self.assertEqual(entry['timeslots'], [], "Timeslots should be empty for an unscheduled class")
self.assertEqual(entry['room_name'], "", "Room name should be empty for an unscheduled class")
These assertions directly address the #TODO comment and ensure that the changelog entry is semantically correct — not just present.
Alternatives Considered
None.
Problem Statement
File:
esp/esp/program/modules/tests/ajaxschedulingmodule.py— Line 192testChangeLogUnscheduledClassescurrently only asserts that the changelog contains exactly one entry after unscheduling a class, but does not verify the content of that entry — specifically that it correctly records an unschedule action (i.e.,room_name == ""andtimeslots == []).The
AJAXChangeLogEntry.toDict()method inmodule_ext.py(lines 331–347) already exposes these fields in the JSON response. A future bug inajax_schedule_deletereg— for example, accidentally logging a schedule action instead of an unschedule action — would not be caught by the current test.Proposed Solution
Extend the test with 4 additional assertions to validate the changelog entry's content, not just its presence.
Before:
After:
These assertions directly address the
#TODOcomment and ensure that the changelog entry is semantically correct — not just present.Alternatives Considered
None.