-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcoursetest.py
71 lines (54 loc) · 2.81 KB
/
coursetest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import unittest
from classes.course import Course, CourseType, Section
from classes.individual import Student, Teacher
from classes.schedule import Schedule
class TestCourseMethods(unittest.TestCase):
def setUp(self):
self.course = Course("test", CourseType.CORE)
self.otherCourse = Course("test2", CourseType.CORE)
self.testTeach = Teacher("test_t", ["test"], [1],[])
self.testStudent = Student("test_s", 9,[])
def test_eq(self):
self.assertNotEqual(self.course, self.otherCourse)
self.otherCourse.courseCode = "test"
self.assertEqual(self.course, self.otherCourse)
def test_add_del(self):
self.course.addReqStudent()
self.assertEqual(self.course.getReqStudents(), 1)
self.course.addTeacher(self.testTeach)
self.assertEqual(self.course.getTeachers(), [self.testTeach])
self.assertEqual(self.course.potentialPeriods, [1])
self.course.removeReqStudent()
self.assertEqual(self.course.getReqStudents(), 0)
self.course.removeTeacher(self.testTeach)
self.assertEqual(self.course.getTeachers(), [])
self.assertEqual(self.course.potentialPeriods, [])
def test_section(self):
self.section = self.course.newSection()
self.otherCourse.addTeacher(self.testTeach)
self.otherCourse.courseCode = "test"
self.otherSection = self.otherCourse.newSection()
self.assertTrue(self.section.sameBaseCourse(self.otherSection))
self.otherSection.courseCode = "test2"
self.assertFalse(self.section.sameBaseCourse(self.otherSection))
self.otherSection.courseCode = "test"
self.section.changePeriod(1)
self.otherSection.changePeriod(1)
self.assertEqual(self.section.getPeriod(), 1)
self.section.changeInstructor(self.testTeach)
self.otherSection.changeInstructor(self.testTeach)
self.assertEqual(self.section.getInstructor(),self.testTeach)
self.section.addStudent(self.testStudent)
self.otherSection.addStudent(self.testStudent)
self.assertEqual(self.section.getStudents(), [self.testStudent])
self.assertEqual(self.section.getStudentCount(), 1)
self.assertTrue(self.section.isTaking(self.testStudent))
self.assertTrue(self.section.isValid())
self.assertEqual(self.section, self.otherSection)
self.assertEqual(str(self.section),"CourseCode: test\n of type: CORE\n with teacher: test_t\n in period: 1\n with students: [\'test_s\']")
self.assertTrue(self.section.isValid())
self.assertEqual(self.section, self.otherSection)
self.section.removeStudent(self.testStudent)
self.assertEqual(self.section.getStudents(),[])
if __name__ == "__main__":
unittest.main()