def test_user_remove_single_coach(self): """ Tests removing a coach from a user's coaches """ u1 = User("u1", 1) u2 = User("u2", 1) u1.add_coach(u2) u1.remove_coach(u2) self.assertEqual(len(u1.coaches), 0) self.assertFalse(u2 in u1.coaches) self.assertFalse(u1 in u2.students)
def remove_coach(self, other): """ Removes the coach from self.coaches and removes the edge for the graph connection :param other: Coach to remove :type other: VisualUser :return: None """ User.remove_coach(self, other) for edge in other.edges: if edge.node1 == other.node and edge.node2 == self.node: other.edges.remove(edge)
def test_user_double_remove_coach(self): """ Tests that an error is raised when double removing a coach """ u1 = User("u1", 1) u2 = User("u2", 1) u1.add_coach(u2) u1.remove_coach(u2) self.assertRaises(MissingCoachError, u1.remove_coach, u2) self.assertEqual(len(u1.coaches), 0) self.assertFalse(u1 in u2.students) self.assertFalse(u2 in u1.coaches)
def test_user_remove_multiple_coaches_same_name(self): """ Tests removing multiple coaches with the same name """ u1 = User("u1", 1) u2 = User("u2", 1) u3 = User("u2", 1) u1.add_coach(u2) u1.add_coach(u3) u1.remove_coach(u2) self.assertEqual(len(u1.coaches), 1) self.assertFalse(u2 in u1.coaches) self.assertTrue(u3 in u1.coaches) self.assertFalse(u1 in u2.students) self.assertTrue(u1 in u3.students)