def test_get_player_correct_data(self): return self.assertIsNotNone( PlayersManagement(server).get_player("Kevin", "Durant", 'latest'))
def test_show_wrong_arg(self): try: PlayersManagement(server).show(None) except NoDataFoundError: pass
def test_get_player_wrong_mode(self): try: PlayersManagement(server).get_player("Kevin", "Durant", 'mode') except KeyError: pass
def test_get_player_wrong_lastname(self): try: PlayersManagement(server).get_player("Kevin", "Name", 'mode') except NoDataFoundError: pass
def test_get_player_wrong_firstname(self): try: PlayersManagement(server).get_player("Name", "Durant", 'mode') except NoDataFoundError: pass
def test_init(self): self.assertIsNotNone(PlayersManagement(server))
def compare_players(): global mode if date is None: set_data() while True: stdscr.clear() stdscr.refresh() title = "COMPARE PLAYERS" season = "1. Compare season stats" career = "2. Compare career stats" back = "3. Back" enter_message = "Enter your choice: " stdscr.clear() stdscr.refresh() to_print = [] to_print.extend((season, career, back, enter_message)) start_x = 5 start_y = 2 print_title(start_y, start_x, title) for item in to_print: start_y += 2 stdscr.addstr(start_y, start_x, item) curses.echo() stdscr.move(start_y, start_x + len(enter_message)) tmp = stdscr.getstr(start_y, start_x + len(enter_message), 1) option = int(tmp.decode("utf-8")) if option == 3: return elif option != 2 and option != 1: wrong_oprion() continue curses.start_color() curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK) stdscr.clear() height, width = stdscr.getmaxyx() stdscr.clear() stdscr.refresh() msg = "Enter player 1 first name:" start_x = int((width // 2) - (len(msg) // 2) - len(msg) % 2) start_y = int((height // 2) - 2) stdscr.addstr(start_y, start_x, msg) tmp = stdscr.getstr(start_y, start_x + len(msg), 20) name_1 = tmp.decode("utf-8") stdscr.clear() stdscr.refresh() msg = "Enter player 1 last name:" start_x = int((width // 2) - (len(msg) // 2) - len(msg) % 2) start_y = int((height // 2) - 2) stdscr.addstr(start_y, start_x, msg) tmp = stdscr.getstr(start_y, start_x + len(msg), 20) surname_1 = tmp.decode("utf-8") stdscr.clear() stdscr.refresh() msg = "Enter player 2 first name:" start_x = int((width // 2) - (len(msg) // 2) - len(msg) % 2) start_y = int((height // 2) - 2) stdscr.addstr(start_y, start_x, msg) tmp = stdscr.getstr(start_y, start_x + len(msg), 20) name_2 = tmp.decode("utf-8") stdscr.clear() stdscr.refresh() msg = "Enter player 2 last name:" start_x = int((width // 2) - (len(msg) // 2) - len(msg) % 2) start_y = int((height // 2) - 2) stdscr.addstr(start_y, start_x, msg) tmp = stdscr.getstr(start_y, start_x + len(msg), 20) surname_2 = tmp.decode("utf-8") if option == 1: mode = 'latest' elif option == 2: mode = 'careerSummary' try: players_mgmt = PlayersManagement(server) player_1 = players_mgmt.get_player(name_1, surname_1, mode).get_stats() player_2 = players_mgmt.get_player(name_2, surname_2, mode).get_stats() PlayersManagement.show(player_1 + player_2) break except NoDataFoundError: msg = "No scores information on name and data, please change data and try again." print_middle(msg) stdscr.getch() except ConnectionError: msg = "Cannot connect to the server" print_middle(msg) stdscr.getch() except KeyError: msg = "Wrong Mode" print_middle(msg) stdscr.getch()