Ejemplo n.º 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')
Ejemplo n.º 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'))
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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))
Ejemplo n.º 7
0
 def test_is_enrolled_empty_class_list(self):
     test_class = ClassList(2)
     self.assertFalse(test_class.is_enrolled('Snoop Dogg'))
Ejemplo n.º 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'))
Ejemplo n.º 9
0
 def test_remove_student_from_empty_list(self):
     test_class = ClassList(1)
     with self.assertRaises(StudentError):
         test_class.remove_student('Mike')
Ejemplo n.º 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'))
Ejemplo n.º 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'))
Ejemplo n.º 12
0
 def test_can_create_class_with_positive_number_of_students(self):
     test_class = ClassList(1)  # Should this be left here or not?
Ejemplo n.º 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'))
Ejemplo n.º 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')
Ejemplo n.º 15
0
    def test_is_class_full(self):
        test_class = ClassList(1)
        test_class.add_student('Amanda')

        self.assertTrue(test_class.is_class_full())
Ejemplo n.º 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())
Ejemplo n.º 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'))
Ejemplo n.º 18
0
 def test_cant_create_class_with_negative_students(self):
     with self.assertRaises(StudentError):
         test_class = ClassList(-1)
Ejemplo n.º 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)
Ejemplo n.º 20
0
 def test_string_empty_class(self):
     test_class = ClassList(2)
     self.assertEqual('', str(test_class))
Ejemplo n.º 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))
Ejemplo n.º 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'))
Ejemplo n.º 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))
Ejemplo n.º 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)
Ejemplo n.º 25
0
 def test_cant_create_class_with_zero_students(self):
     with self.assertRaises(StudentError):
         test_class = ClassList(0)