コード例 #1
0
 def test_addCourse_removeItem_lecture(self):
     """
         Tests that a lecture is added to schedule and then removed
     """
     myLecture = self.myCourseCatalog.searchCoursesThroughPartialName("COEN428")[0].lecture_set.all()[0]
     mySchedule = Schedule()
     mySchedule.add_item(myLecture)
     coursesInMySchedule = mySchedule.view_schedule()
     TestCase.assertIn(self, myLecture, coursesInMySchedule, "The course was not added to the schedule")
     mySchedule.remove_item(myLecture)
     coursesInMySchedule = mySchedule.view_schedule()
     TestCase.assertEqual(self, len(coursesInMySchedule), 0, "The course was not removed from the schedule")
コード例 #2
0
 def test_getCourseBasedOnDepartment(self):
     """
         Test adds 3 courses, and retrieves only the 2
         with department SOEN
     """
     myRetrievedCourses = self.myCourseCatalog.searchCoursesThroughPartialName(
         "SOEN")
     courses = []
     for c in myRetrievedCourses:
         courses.append(c.name)
     TestCase.assertEqual(
         self, 2, len(myRetrievedCourses),
         "The correct amount of courses was not retrieved")
     TestCase.assertIn(self, "Test 1", courses,
                       "The  course was not retrieved from the database")
     TestCase.assertIn(self, "Test 2", courses,
                       "The  course was not retrieved from the database")
コード例 #3
0
 def test_getCourseBasedOnCreditRange(self):
     """
         Test adds 3 courses, and retrieves only the 2
         courses with 3 to 3.5 credits
     """
     myRetrievedCourses = self.myCourseCatalog.searchCoursesByCredits(
         3, 3.5)
     courses = []
     for c in myRetrievedCourses:
         courses.append(c.name)
     TestCase.assertEqual(
         self, 2, len(myRetrievedCourses),
         "The correct amount of courses was not retrieved")
     TestCase.assertIn(self, "Test 0", courses,
                       "The  course was not retrieved from the database")
     TestCase.assertIn(self, "Test 1", courses,
                       "The  course was not retrieved from the database")
コード例 #4
0
 def test_addCourse_removeItem_lab(self):
     """
         Tests that a lab and its accompanying tutorial and
         lecture are added to schedule and then removed
     """
     myLecture = self.myCourseCatalog.searchCoursesThroughPartialName("COEN428")[0].lecture_set.all()[0]
     myTutorial = self.myCourseCatalog.searchCoursesThroughPartialName("COEN428")[0].tutorial_set.all()[0]
     myLab = self.myCourseCatalog.searchCoursesThroughPartialName("COEN428")[0].lab_set.all()[0]
     mySchedule = Schedule()
     mySchedule.add_item(myLab)
     coursesInMySchedule = mySchedule.view_schedule()
     TestCase.assertIn(self, myLab, coursesInMySchedule, "The course was not added to the schedule")
     TestCase.assertIn(self, myTutorial, coursesInMySchedule, "The course was not added to the schedule")
     TestCase.assertIn(self, myLecture, coursesInMySchedule, "The course was not added to the schedule")
     mySchedule.remove_item(myLab)
     coursesInMySchedule = mySchedule.view_schedule()
     TestCase.assertEqual(self, len(coursesInMySchedule), 0, "The course was not removed from the schedule")
コード例 #5
0
 def test_getCourseBasedOnPartialNumber(self):
     """
         Test adds 3 courses, and retrieves the 3 with
         course number or name containing 1
     """
     myRetrievedCourses = self.myCourseCatalog.searchCoursesThroughPartialName(
         "1")
     courses = []
     for c in myRetrievedCourses:
         courses.append(c.name)
     TestCase.assertEqual(
         self, 3, len(myRetrievedCourses),
         "The correct amount of courses was not retrieved")
     TestCase.assertIn(self, "Test 0", courses,
                       "The  course was not retrieved from the database")
     TestCase.assertIn(self, "Test 1", courses,
                       "The  course was not retrieved from the database")
     TestCase.assertIn(self, "Test 2", courses,
                       "The  course was not retrieved from the database")
コード例 #6
0
ファイル: test_utils.py プロジェクト: f-tepel/django-skeleton
def format_failed_response_check(instance: TestCase, res: HttpResponse):
  body = json.loads(res.content)
  failed_codes: [int] = [400, 401, 403, 404]

  instance.assertIn(res.status_code, failed_codes)
  instance.assertIsNotNone(body.get('detail'))