def test_structure_initialization(self): team = Team(self.__TEAM_NAME) self.assertEqual(self.__TEAM_NAME, self.team.name) self.assertDictEqual({}, team.members) with self.assertRaises(ValueError) as ex: Team("T3stNam3") expected = f"Team Name can contain only letters!" self.assertEqual(expected, str(ex.exception))
def test_add_method(self): team1 = Team("FirstTeam") team2 = Team("SecondTeam") team1.members = {"Gergi": 10} team2.members = {"Ivan": 20} x = team1 + team2 self.assertEqual("FirstTeamSecondTeam", x.name) self.assertEqual({"Gergi": 10, "Ivan": 20}, x.members)
def test_gt_method(self): team1 = Team("FirstTeam") team2 = Team("SecondTeam") team2.members = {"Ivan": 20} x = team1 < team2 y = team1 > team2 self.assertEqual(True, x) self.assertEqual(False, y)
def test_adding_two_instances_of_team(self): expected = Team(f"{self.__TEAM_NAME}{self.__TEAM_NAME1}") expected.add_member(**self.__MEMBERS) expected.add_member(**self.__MEMBERS1) result = self.team + self.team1 self.assertEqual(expected.name, result.name) self.assertDictEqual(expected.members, result.members)
from project.player import Player from project.team import Team p = Player("Pall", 1, 3, 5, 7) print("Player name:", p.name) print("Points sprint:", p._Player__sprint) print("Points dribble:", p._Player__dribble) print("Points passing:", p._Player__passing) print("Points shooting:", p._Player__shooting) print("\ncalling the __str__ method") print(p) print("\nAbout the team") t = Team("Best", 10) print("Team name:", t._Team__name) print("Teams points:", t._Team__rating) print("Teams players:", len(t._Team__players)) print(t.add_player(p)) print(t.add_player(p)) print("Teams players:", len(t._Team__players)) print(t.remove_player("Pall")) print(t.remove_player("Pall"))
def test_len_method(self): team2 = Team("SecondTeam") team2.members = {"Ivan": 20} x = len(team2) self.assertEqual(1, x)
def setUp(self): self.team = Team("TestName")
def test_team_remove_fail(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) result = "Player Pall not found" exp = t.remove_player("Pall") self.assertEqual(exp, result)
def test_team_remove_successful(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) t.add_player(p) exp = t.remove_player("Pall") self.assertEqual(exp, p)
def test_team_add_fail(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) t.add_player(p) self.assertEqual(t.add_player(p), "Player Pall has already joined")
def test_team_add_successful(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) self.assertEqual(t.add_player(p), "Player Pall joined team Best")
def test_team_init(self): t = Team("Best", 10) self.assertEqual(t.name, "Best") self.assertEqual(t.rating, 10) self.assertEqual(len(t.players), 0)
def setUp(self) -> None: self.team = Team(self.__TEAM_NAME) self.team1 = Team(self.__TEAM_NAME1) self.team.add_member(**self.__MEMBERS) self.team1.add_member(**self.__MEMBERS1)