def testUsersInCourse(self): inCS101c = CourseAttempt.query( CourseAttempt.course == ndb.Key(Course, 'udacitycs101'), CourseAttempt.completed == True).fetch(5) self.assertEqual( len(inCS101c), 1, "Wrong number of students completed CS101: %s should be 1" % len(inCS101c)) incomplete = CourseAttempt.query( CourseAttempt.completed == False).fetch(5) self.assertEqual( len(incomplete), 1, "Wrong number of total course enrollments %s should be 1" % len(incomplete)) completed = CourseAttempt.query( CourseAttempt.completed == True).fetch(5) self.assertEqual( len(completed), 2, "Wrong number of total course enrollments %s should be 2" % len(completed))
def testStudentsInClass(self): uinCS101 = CourseAttempt.query( CourseAttempt.course == ndb.Key(Course, 'udacitycs101'), ).get() self.assertIsNotNone(uinCS101, "Zero students in class, should be non-zero") self.assertEqual( uinCS101.student, self.u1.key, "Wrong user %s, should be %s" % (uinCS101.student, self.u1.key))
def testUsersInCourse(self): inCS101c = CourseAttempt.query( CourseAttempt.course == ndb.Key(Course, 'udacitycs101'), CourseAttempt.completed == True).fetch(5) self.assertEqual(len(inCS101c), 1, "Wrong number of students completed CS101: %s should be 1" % len(inCS101c)) incomplete = CourseAttempt.query( CourseAttempt.completed == False ).fetch(5) self.assertEqual(len(incomplete), 1, "Wrong number of total course enrollments %s should be 1" % len(incomplete)) completed = CourseAttempt.query( CourseAttempt.completed == True ).fetch(5) self.assertEqual(len(completed), 2, "Wrong number of total course enrollments %s should be 2" % len(completed))
def testStudentsInClass(self): uinCS101 = CourseAttempt.query( CourseAttempt.course == ndb.Key(Course, 'udacitycs101'), ).get() self.assertIsNotNone(uinCS101, "Zero students in class, should be non-zero") self.assertEqual(uinCS101.student, self.u1.key, "Wrong user %s, should be %s" % (uinCS101.student, self.u1.key) )
def testGetAllAttempts(self): attempts = CourseAttempt().query().fetch(10) self.assertEqual(len(attempts), 3, "Wrong number of attempts %s, should be 3" % attempts)