Пример #1
0
 def test_add_some_example_student(self):
     test_class = ClassList(2)
     test_class.add_student('Grace Smith')
     test_class.add_student('Bella Swan')
     test_class.add_student('Alina Ly')
     with self.assertRaises(StudentError):
         test_class.remove_student('Harmony Lee')
Пример #2
0
    def test_list_for_correct_index_of_none(self):
        test_class = ClassList(3)
        test_class.add_student('Larry')
        test_class.add_student('Curly')
        test_class.add_student('Moe')

        self.assertEqual(None, test_class.index_of_student('Harry'))
        self.assertEqual(None, test_class.index_of_student('Hermione'))
        self.assertEqual(None, test_class.index_of_student('Ron'))

        self.assertIsNone(test_class.index_of_student('Mike'))
Пример #3
0
    def test_add_remove_student(self):
        test_class = ClassList(2)
        test_class.add_student('Mike')
        test_class.add_student('Jake')
        test_class.remove_student('Mike')

        self.assertNotIn("Mike", test_class.class_list)
Пример #4
0
    def test_remove_student_not_in_list(self):
        test_class = ClassList(2)
        test_class.add_student('Mike')
        test_class.add_student('Jake')

        with self.assertRaises(StudentError):
            test_class.remove_student('Tom')
Пример #5
0
    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)
Пример #6
0
 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))
Пример #7
0
 def test_is_enrolled_empty_class_list(self):
     test_class = ClassList(2)
     self.assertFalse(test_class.is_enrolled('Snoop Dogg'))
Пример #8
0
 def test_is_erolled_returns_false(self):
     test_class = ClassList(2)
     test_class.add_student('Mike')
     test_class.add_student('Jake')
     self.assertFalse(test_class.is_enrolled('Amanda'))
Пример #9
0
 def test_remove_student_from_empty_list(self):
     test_class = ClassList(1)
     with self.assertRaises(StudentError):
         test_class.remove_student('Mike')
Пример #10
0
 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'))
Пример #11
0
 def test_index_of_student_returns_none_on_empty_list(self):
     test_class = ClassList(3)
     self.assertIsNone(test_class.index_of_student('Mike'))
Пример #12
0
 def test_can_create_class_with_positive_number_of_students(self):
     test_class = ClassList(1)  # Should this be left here or not?
Пример #13
0
 def test_index_of_student_when_list_is_not_empty(self):
     test_class = ClassList(2)
     test_class.add_student('Student Number1')
     test_class.add_student('Student Number2')
     self.assertIsNone(test_class.index_of_student('Student Number3'))
Пример #14
0
 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')
Пример #15
0
    def test_is_class_full(self):
        test_class = ClassList(1)
        test_class.add_student('Amanda')

        self.assertTrue(test_class.is_class_full())
Пример #16
0
    def test_is_class_not_full(self):
        test_class = ClassList(2)
        test_class.add_student('Amanda')

        self.assertFalse(test_class.is_class_full())
Пример #17
0
 def test_verify_if_student_is_enrolled(self):
     test_class = ClassList(2)
     test_class.add_student('Test Student1')
     test_class.add_student('Test Student2')
     self.assertFalse(test_class.is_enrolled('Test Student3'))
Пример #18
0
 def test_cant_create_class_with_negative_students(self):
     with self.assertRaises(StudentError):
         test_class = ClassList(-1)
Пример #19
0
 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)
Пример #20
0
 def test_string_empty_class(self):
     test_class = ClassList(2)
     self.assertEqual('', str(test_class))
Пример #21
0
 def test_is_class_full_when_class_is_empty(self):
     test_class = ClassList(3)
     test_class.add_student('Amazing Student1')
     test_class.add_student('Amazing Student2')
     self.assertFalse(test_class.is_class_full(3))
Пример #22
0
    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'))
Пример #23
0
 def test_is_class_full_when_class_is_full(self):
     test_class = ClassList(2)
     test_class.add_student('New Student1')
     test_class.add_student('New Student2')
     self.assertTrue(test_class.is_class_full(2))
Пример #24
0
 def test_index_of_student_is_none_if_classlist_is_empty(self):
     test_class = ClassList(2)
     index = test_class.index_of_student('Test Student')
     self.assertIsNone(index)
Пример #25
0
 def test_cant_create_class_with_zero_students(self):
     with self.assertRaises(StudentError):
         test_class = ClassList(0)