def test_is_empty_is_not_full(self): test_class = ClassList(5) test_class2 = ClassList(2) test_class.add_student('Student1') test_class.add_student('Student2') test_class.add_student('Student3') self.assertFalse(test_class.is_class_full(test_class)) self.assertFalse(test_class.is_class_full(test_class2))
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_student_not_in_class_is_not_enrolled(self): test_class = ClassList(4) test_class.add_student('Alice') test_class.add_student('Bob') is_carl_enrolled = test_class.is_enrolled('Carl') self.assertFalse(is_carl_enrolled)
def test_remove_student_not_in_list(self): test_class = ClassList(2) test_class.add_student('Ooh') test_class.add_student('Ah') self.assertEquals(2, len(test_class.class_list)) with self.assertRaises(StudentError): test_class.remove_student('Croomple')
def test_remove_student_who_is_not_in_the_list_raises_student_error(self): test_class = ClassList(4) test_class.add_student('Alice') test_class.add_student('Larry') # remove "carl'", expect a StudentError # action and assert together with self.assertRaises(StudentError): # action test_class.remove_student('Carl')
def test_index_of_student_who_is_not_in_class_to_be_none(self): test_class = ClassList(2) test_class.add_student('Harry') test_class.add_student('Sally') self.assertEqual(1, test_class.index_of_student('Harry')) self.assertEqual(2, test_class.index_of_student('Sally')) self.assertIsNone(test_class.index_of_student('Berry'))
def test_index_of_student_in_empty_list_returns_none_when_list_not_empty(self): test_class = ClassList(5) test_class.add_student('Tony Micelli') test_class.add_student('Angela Bower') test_class.add_student('Samantha Micelli') index_of_missing_student = test_class.index_of_student('Mona Robinson') self.assertIsNone(index_of_missing_student)
def test_is_class_full_returns_true_when_class_is_full(self): test_class = ClassList(3) student_a = "Michael Burnham" student_b = "Philippa Georgiou" student_c = "Gabriel Lorca" test_class.add_student(student_a) test_class.add_student(student_b) test_class.add_student(student_c) self.assertTrue(test_class.is_class_full())
def test_remove_student_not_in_list(self): student_a = "Ben Sisko" student_b = "Kira Nerys" student_c = "Gul Dukat" test_class = ClassList(2) test_class.add_student(student_a) test_class.add_student(student_b) with self.assertRaises(StudentError): test_class.remove_student(student_c)
def test_is_class_full(self): #tests whether is_class_full works as intended test_class = ClassList(1) test_class.add_student('Jordan') self.assertTrue(test_class.is_class_full()) test_class_two = ClassList(2) test_class_two.add_student('Ben') test_class_two.add_student('Neb') self.assertTrue(test_class_two.is_class_full())
def test_index_of_student_student_not_present(self): test_class = ClassList(2) self.assertIsNone(test_class.index_of_student('Jeff')) test_class.add_student('student_1') test_class.add_student('student_2') self.assertEqual(1, test_class.index_of_student('student_1')) self.assertEqual(2, test_class.index_of_student('student_2')) self.assertIsNone(test_class.index_of_student('student_3'))
def test_add_student_removed(self): test_class = ClassList(2) test_class.add_student('Test Student') test_class.remove_student('Test Student') test_class.add_student('Another Test Student') test_class.remove_student('Another Test Student') self.assertNotIn('Test Student', test_class.class_list) self.assertNotIn('Another Test Student', test_class.class_list)
def test_if_student_not_in_class_is_enrolled(self): student_a = "Ben Sisko" student_b = "Kira Nerys" student_c = "Gul Dukat" student_d = "Aurthur Dent" test_class = ClassList(2) test_class.add_student(student_a) test_class.add_student(student_b) test_class.add_student(student_c) self.assertFalse(test_class.is_enrolled(student_d))
def test_remove_student_who_is_not_in_the_list_raises_student_error(self): # Arrange test_class = ClassList(4) test_class.add_student('Alice') test_class.add_student('Bob') # Remove 'Carl', expect a StudentError # Action and Assert together with self.assertRaises(StudentError): # Action test_class.remove_student('Carl')
def test_is_class_full_with_empty_or_partial_class(self): test_class = ClassList(3) # Test before adding students self.assertFalse(test_class.is_class_full()) test_class.add_student('Harry') test_class.add_student('Ron') # Test after adding students self.assertFalse(test_class.is_class_full())
def test_student_not_in_class_is_not_enrolled(self): # Arrange test_class = ClassList(4) # example class with 4 students test_class.add_student('Alice') test_class.add_student('Bob') # carl is not registered # Action is_carl_enrolled = test_class.is_enrolled('Carl') # Assert self.assertFalse(is_carl_enrolled)
def test_add_remove_studenterror(self): #Create new list class test_class = ClassList(1) # Add Example Student test_class.add_student('Ben') with self.assertRaises(StudentError): test_class.remove_student('Sally') # ## TODO write a test that removes a student from an empty list, and asserts a StudentError is raised #Create new list class test_class = ClassList(1) with self.assertRaises(StudentError): test_class.remove_student('Sally')
def test_is_class_full(self): test_class = ClassList(4) test_class.add_student('Farmaajo') test_class.add_student('Mukami') test_class.add_student('Abdi') test_class.add_student('Bisharo') self.assertTrue(test_class.is_class_full())
def test_is_class_full(self): test_class = ClassList(4) test_class.add_student('asdf') test_class.add_student('af') test_class.add_student('ffff') test_class.add_student('asdfdsa') self.assertTrue(test_class.class_is_full())
def test_class_not_full(self): test_class_not_full = ClassList(5) test_class_empty = ClassList(5) test_class_not_full.add_student('asdf') test_class_not_full.add_student('af') test_class_not_full.add_student('ffff') test_class_not_full.add_student('asdfdsa') self.assertFalse(test_class_not_full.class_is_full()) self.assertFalse(test_class_empty.class_is_full())
def test_index_of_student_for_absent_name_returning_none(self): test_class = ClassList(3) self.assertIsNone(test_class.index_of_student('Harry')) test_class.add_student('Harry') test_class.add_student('Hermione') test_class.add_student('Ron') self.assertIsNone(test_class.index_of_student('Malfoy'))
def test_add_new_remove_non_exist_student(self): test_class = ClassList(3) test_class.add_student('Test Student') test_class.add_student('Nate Walter') test_class.add_student('Known Student') with self.assertRaises(StudentError): test_class.remove_student('Unknown Student')
def test_is_class_empty(self): test_list = ClassList(4) test_list.add_student('James Hetfield') test_list.add_student('Lars Ulrich') test_list.add_student('Kirk Hammett') self.assertFalse(test_list.is_class_full())
def test_remove_student_notIn_list(self): test_class = ClassList(2) test_class.add_student('Michael Jackson') test_class.add_student('Jelly Roll') test_class.add_student('Anna') with self.assertRaises(StudentError): test_class.remove_student('Anna')
def test_index_of_students(self): test_class = ClassList(2) test_class.add_student('Mich') test_class.add_student('Micha') test_class.add_student('Michael') self.assertIsNone(test_class.index_of_student('Jake'))
def test_remove_student_that_is_not_in_list(self): test_class = ClassList(3) test_class.add_student('Marco') test_class.add_student('Sophie') test_class.add_student('Petricore') with self.assertRaises(StudentError): test_class.remove_student('Gus')
def test_is_class_full(self): test_class = ClassList(3) test_class.add_student('Harry') test_class.add_student('Hermione') self.assertFalse(test_class.is_class_full()) test_class.add_student('Ron') self.assertTrue(test_class.is_class_full())
def test_string_with_students_enrolled(self): test_class = ClassList(3) test_class.add_student('Taylor Swift') test_class.add_student('Kanye West') test_class.add_student('Scott Kim') self.assertEqual('Taylor Swift, Kanye West, Scott Kim', str(test_class))
def test_student_not_in_list(self): test_class = ClassList(3) test_class.add_student('Harry') test_class.add_student('Hermione') test_class.add_student('Ron') self.assertIsNone(test_class.index_of_student('Jimmy'))
def test_is_class_full_with_full_class(self): test_class = ClassList(3) test_class.add_student('Harry') test_class.add_student('Ron') test_class.add_student('Hermoine') self.assertTrue(test_class.is_class_full)