def test_add_student_check_student_in_list(self): test_class = ClassList(2) test_class.add_student('Test Student') self.assertIn('Test Student', test_class.class_list) test_class.add_student('Another Test Student') self.assertIn('Test Student', test_class.class_list) self.assertIn('Another Test Student', test_class.class_list)
def test_index_of_student_student_present(self): test_class = ClassList(3) test_class.add_student('Harry') test_class.add_student('Hermione') test_class.add_student('Ron') self.assertEqual(1, test_class.index_of_student('Harry')) self.assertEqual(2, test_class.index_of_student('Hermione')) self.assertEqual(3, test_class.index_of_student('Ron')) # This assert passes, but it's redundant - the first assert statement will fail if # the method call returns None self.assertIsNotNone(test_class.index_of_student('Harry'))
def test_string_with_students_enrolled(self): test_class = ClassList(2) test_class.add_student('Taylor Swift') test_class.add_student('Kanye West') self.assertEqual('Taylor Swift, Kanye West', str(test_class))
def test_fail_with_student_who_is_not_enrolled(self): test_class = ClassList(2) test_class.add_student('Kirk Cousins') test_class.add_student('Deshaun Watson') self.assertFalse(test_class.is_enrolled('Joe'))
def test_is_enrolled_when_student_present(self): test_class = ClassList(2) test_class.add_student('Snoop Dogg') test_class.add_student('Martha Stewart') self.assertTrue(test_class.is_enrolled('Snoop Dogg')) self.assertTrue(test_class.is_enrolled('Martha Stewart'))
def test_remove_student_not_in_class_student_error(self): test_class = ClassList(2) test_class.add_student('Test Student') test_class.add_student('Joe') with self.assertRaises(StudentError): test_class.remove_student('Emily')
def test_add_remove_student_ensure_removed(self): test_class = ClassList(2) test_class.add_student('Test Student') test_class.remove_student('Test Student') self.assertNotIn('Test Student', test_class.class_list)
def test_add_student_already_in_list(self): test_class = ClassList(2) test_class.add_student('Test Student') with self.assertRaises(StudentError): test_class.add_student('Test Student')
def test_class_is_full_method_when_class_is_full(self): test_class = ClassList(2) test_class.add_student('Kirk Cousins') test_class.add_student('Deshaun Watson') full = test_class.is_class_full() self.assertTrue(full)
def test_search_results_in_none_for_student_not_in_class(self): test_class = ClassList(2) test_class.add_student('Kirk Cousins') test_class.add_student('Deshaun Watson') index = test_class.index_of_student('Tom Brady') self.assertIsNone(index)