예제 #1
0
    def test_is_enrolled(self):
        table = EnrollTable(35)
        student = StudentNode("999670", "ART", "Tosin", "Kuye")
        student1 = StudentNode("999635", "SCI", "Satoshi", "Nakamoto")
        student2 = StudentNode("999600", "ART", "Levi", "Ackermann")
        student3 = StudentNode("999599", "ART", "Tosin", "Kuye")
        student4 = StudentNode("555555", "SCI", "Satoshi", "Nakamoto")
        student5 = StudentNode("534125", "SCI", "Satoshi", "Monkery")
        student6 = StudentNode("211122", "SCI", "Satoshi", "Masaaas")
        table.insert(student)
        table.insert(student1)
        table.insert(student2)
        table.insert(student3)
        table.insert(student4)
        table.insert(student5)
        table.insert(student6)

        self.assertTrue(table.isEnrolled(student.getID()))
        self.assertTrue(table.isEnrolled(student1.getID()))
        self.assertTrue(table.isEnrolled(student2.getID()))
        self.assertTrue(table.isEnrolled(student3.getID()))
        self.assertTrue(table.isEnrolled(student4.getID()))
        self.assertTrue(table.isEnrolled(student5.getID()))
        table.remove(student.getID())
        table.remove(student1.getID())
        self.assertFalse(table.isEnrolled(student.getID()))
        self.assertFalse(table.isEnrolled(student1.getID()))

        self.assertEqual(table.size(), 5)
예제 #2
0
def dropStudent(file, enrollTable: EnrollTable, queue: PriorityQueue) -> None:
    """This helper method reads in a file and drops students from the class with a given ID."""
    pc = PrintColour()
    assert isinstance(enrollTable, EnrollTable), "Not an EnrollTable."
    assert isinstance(queue, PriorityQueue), "Not a PriorityQueue"
    for line in file.readlines():
        studentId, faculty, fname, lname = lineSplitter(line)
        if studentId is None:
            pass
        else:
            student = enrollTable.remove(studentId)
            if student is False:
                pc.printout(
                    f"WARNING:There is no student {fname} {lname}, (ID: {studentId}) currently enrolled and cannot be dropped!",
                    color="RED")
            else:
                try:
                    if not queue.isEmpty():
                        item = queue.dequeue()

                        item.setNext(None)
                        item.setPrev(None)
                        enrollTable.insert(item)
                except AssertionError as e:
                    pc.printout(e.args[0], color="RED")
예제 #3
0
    def test_remove_table(self):
        table = EnrollTable(35)
        student = StudentNode("999670", "ART", "Tosin", "Kuye")
        student1 = StudentNode("999635", "SCI", "Satoshi", "Nakamoto")
        student2 = StudentNode("999600", "ART", "Levi", "Ackermann")
        student3 = StudentNode("999599", "ART", "Tosin", "Kuye")
        student4 = StudentNode("555555", "SCI", "Satoshi", "Nakamoto")
        student5 = StudentNode("534125", "SCI", "Satoshi", "Monkery")
        student6 = StudentNode("211122", "SCI", "Satoshi", "Masaaas")
        table.insert(student)
        table.insert(student1)
        table.insert(student2)
        table.insert(student3)
        table.insert(student4)
        table.insert(student5)
        table.insert(student6)

        t = table.remove(student1.getID())
        self.assertEqual(table.tableSize, 6)
        self.assertTrue(t)
        table.remove("233433")
        table.remove(student6.getID())
        self.assertEqual(table.tableSize, 5)
예제 #4
0
    def test_assert_empty(self):
        table = EnrollTable(35)
        student = StudentNode("999670", "ART", "Tosin", "Kuye")
        student1 = StudentNode("999635", "SCI", "Satoshi", "Nakamoto")
        student2 = StudentNode("999600", "ART", "Levi", "Ackermann")
        student3 = StudentNode("999599", "ART", "Tosin", "Kuye")

        table.insert(student)
        table.insert(student1)
        table.insert(student2)
        table.insert(student3)
        self.assertFalse(table.isEmpty())
        table.remove(student.getID())
        table.remove(student1.getID())
        table.remove(student2.getID())
        table.remove(student3.getID())

        self.assertTrue(table.isEmpty())