def test_invalidCourse(self): course1 = Course(title="Course 14", instructor=self.instructor) course1.save() course2 = Course(title="Course 15") course2.save() response = self.client.post("/ViewAllCourses/", {"currentCourse": "a;lsdkfja"}) self.assertEqual(response.context["courses"], ["Course 14", "Course 15"], msg="Entering an invalid course fails" "to post all courses") self.assertEqual(response.context["instructor"], "Course Does not Exist", msg="Entering invalid coures fails to " "post error message through " "currentCourse") self.assertEqual(response.context["allSections"], [], msg="Entering invalid course fails to post empty list" "of sections") self.assertEqual( response.context["allTA"], [], msg="Entering invalid course fails to post empty list of TA") self.assertEqual( response.context["currentCourse"], "Please Enter Valid Course", msg= "Entering an invalid course fails to return currentCourse as correct message" )
def test_manyOfEach(self): course1 = Course(title="Course 14", instructor=self.instructor) course1.save() course2 = Course(title="Course 15") course2.save() section1 = Section(title="Section 14", course=course1, emp=self.ta1) section1.save() section2 = Section(title="Section 15", course=course1, emp=self.ta2) section2.save() response = self.client.post("/ViewAllCourses/", {"currentCourse": "Course 14"}) self.assertEqual(response.context["courses"], ["Course 14", "Course 15"], msg="Entering an invalid course fails" "to post all courses") self.assertEqual( response.context["instructor"], "Jim Rachminoff", msg= "instructor value is invalid after entering course with instructor" ) self.assertEqual( response.context["allSections"], [("Section 14", "Hungarian", "Waltz"), ("Section 15", "Max", "Volume")], msg= "Entering a course with multiple sections and TAs fails to return correct list" ) self.assertEqual( response.context["allTA"], [("Hungarian", "Waltz"), ("Max", "Volume")], msg="Entering a course with multiple TAs fails to post correct list" )
def test_oneOfEach(self): course1 = Course(title="Course 14", instructor=self.instructor) course1.save() course2 = Course(title="Course 15") course2.save() section = Section(title="Section 14", course=course1, emp=self.ta1) section.save() response = self.client.post("/ViewAllCourses/", {"currentCourse": "Course 14"}) self.assertEqual(response.context["courses"], ["Course 14", "Course 15"], msg="Entering a valid course fails" "to post all courses") self.assertEqual( response.context["instructor"], "Jim Rachminoff", msg= "instructor value is invalid after entering course with instructor" ) self.assertEqual( response.context["allSections"], [("Section 14", "Hungarian", "Waltz")], msg= "allSections value is invalid after entering course with one TA and one section" ) self.assertEqual( response.context["allTA"], [("Hungarian", "Waltz")], msg= "allTA value is invalid after entering course with one TA and one section" )
def test_noTA(self): course1 = Course(title="Course 14", instructor=self.instructor) course1.save() section1 = Section(title="Section 14", course=course1) section1.save() course2 = Course(title="Course 15") course2.save() response = self.client.post("/ViewAllCourses/", {"currentCourse": "Course 14"}) self.assertEqual(response.context["courses"], ["Course 14", "Course 15"], msg="Entering a valid course fails" "to post all courses") self.assertEqual( response.context["instructor"], "Jim Rachminoff", msg= "Instructor value invalid after entering course with no instructor" ) self.assertEqual( response.context["allSections"], [("Section 14", "No one", "assigned")], msg= "Entering a course with sections and no TA fails to procure correct list" ) self.assertEqual( response.context["allTA"], [], msg="Entering a course with no TAs fails to post empty list of TA")
def test_someCourses(self): class5 = Course(title="Class 5") class5.save() class6 = Course(title="Class 6") class6.save() self.assertEqual( courseList(), [class5.title, class6.title], msg="Making a list of courses when the DB has some entries " "return a list of every element")
def setUp(self): self.employeeList = {"*****@*****.**":["Fleetwood","Mac","Instructor","J","123"], "":["","","Instructor","",""]} self.empObj = list() self.empObj = createEmp(self.employeeList, self.empObj) self.course1 = Course(title="Class 7", instructor=self.empObj[0]) self.course1.save() self.course2 = Course(title="Class 8") self.course2.save() self.course3 = Course(title="Class 9", instructor=self.empObj[1]) self.course3.save()
def setUp(self): self.employeeList = { "*****@*****.**": ["Jim", "Gaffigan", "Instructor", "T", "123"], "*****@*****.**": ["Bill", "Burr", "Instructor", "B", "789"], "*****@*****.**": ["Bert", "Kreischer", "TA", "A", "456"] } self.empObj = list() self.empObj = createEmp(self.employeeList, self.empObj) self.course1 = Course(title="Comedy 251", instructor=self.empObj[0]) self.course1.save() self.course2 = Course(title="Comedy 351") self.course2.save()
def setUp(self): self.employeeList = { "*****@*****.**": ["Jim", "Gaffigan", "Instructor", "T", "123"], "*****@*****.**": ["Bert", "Kreischer", "TA", "A", "456"] } self.empObjects = list() self.empObjects = createEmp(self.employeeList, self.empObjects) self.course = Course(title="Comedy 252", instructor=self.empObjects[0]) self.course.save() self.course2 = Course(title="Comedy 351") self.course.save() self.section = Section(title="Lab 101", course=self.course, emp=self.empObjects[1]) self.section.save()
def test_getCourses(self): course1 = Course(title="Course 14", instructor=self.instructor) course1.save() course2 = Course(title="Course 15") course2.save() response = self.client.get("/ViewAllCourses/") self.assertEqual( response.context["courses"], ["Course 14", "Course 15"], msg= "Rendering View Courses page fails to return an empty list when there are no course in the " "DB") self.assertEqual( response.context["currentCourse"], "Select a Course", msg= "Rendering the View Courses page for the first time fails to have message " "\"Select a Course\"")
def setUp(self): self.client = Client() self.employeeList = {"*****@*****.**":["john","doe","Instructor","a","123"], "*****@*****.**":["james","doe","Instructor","a","123"], "*****@*****.**":["jane","doe","TA","a","123"], "*****@*****.**":["jack","doe","Supervisor","a","123"]} self.empObj = list() self.empObj = createEmp(self.employeeList, self.empObj) self.courseNoInstructor = Course(title="Class 3") self.courseNoInstructor.save() self.courseHasInstructor = Course(title="Class 4", instructor=self.empObj[0]) self.courseHasInstructor.save() self.section1 = Section(title="Section 3", course=self.courseNoInstructor) self.section1.save() self.section2 = Section(title="Section 4", course=self.courseHasInstructor) self.section2.save() self.courses = ["Class 3", "Class 4"]
def setUp(self): self.employeeList = { "*****@*****.**": ["Jim", "Gaffigan", "Instructor", "T", "123"], "*****@*****.**": ["Bert", "Kreischer", "Supervisor", "A", "456"] } self.empObj = list() self.empObj = createEmp(self.employeeList, self.empObj) self.course = Course(title="Comedy 251", instructor=self.empObj[0]) self.course.save()
def setUp(self): self.employeeList = { "*****@*****.**": ["Bob", "Dog", "TA", "B", "Bark"], "*****@*****.**": ["Hannah", "Dog", "TA", "B", "Bark"] } self.empObj = list() self.empObj = createEmp(self.employeeList, self.empObj) self.course = Course(title="Class 11") self.course.save() self.ta1 = self.empObj[0] self.ta2 = self.empObj[1]
def test_noInstructor(self): course1 = Course(title="Course 14", instructor=self.instructor) course1.save() course2 = Course(title="Course 15") course2.save() response = self.client.post("/ViewAllCourses/", {"currentCourse": "Course 15"}) self.assertEqual(response.context["courses"], ["Course 14", "Course 15"], msg="Entering a valid course fails" "to post all courses") self.assertEqual( response.context["instructor"], "Instructor Not Assigned Yet", msg= "Instructor value invalid after entering course with no instructor" ) self.assertEqual( response.context["allSections"], [], msg="Entering course with no sections fails to procure" "the appropriate list") self.assertEqual( response.context["allTA"], [], msg="Entering course with no TA fails to procure an empty list")
def setUp(self): self.employeeList = { "*****@*****.**": ["john", "doe", "Instructor", "a", "123"], "*****@*****.**": ["james", "doe", "Instructor", "a", "123"], "*****@*****.**": ["jane", "doe", "TA", "a", "123"], "*****@*****.**": ["jack", "doe", "Supervisor", "a", "123"] } self.empObj = list() self.empObj = createEmp(self.employeeList, self.empObj) self.courseNoInstructor = Course(title="Class 1", instructor=None) self.courseNoInstructor.save() self.courseHasInstructor = Course.objects.create( title="Class 2", instructor=self.empObj[0]) self.section1 = Section.objects.create(title="Section 1", course=self.courseNoInstructor) self.section2 = Section.objects.create(title="Section 2", course=self.courseHasInstructor)
def test_sameName(self): class5 = Course(title="Class 5") class5.save() class6 = Course(title="Class 6") class6.save() class7_1 = Course(title="Class 7") class7_1.save() class7_2 = Course(title="Class 7") class7_2.save() class7_3 = Course(title="Class 7") class7_3.save() class7_4 = Course(title="Class 7") class7_4.save() self.assertEqual( courseList(), [ class5.title, class6.title, class7_1.title, class7_1.title, class7_1.title, class7_1.title ], msg= "Making a list courses when some names have repeats fails to return correct list" )