def setUp(self):
     if done is False:
         setUpHelper(self)
     self.topdict = tr_api.listTournamentPlayers(1)
     self.topdict2 = tr_api.removePlayer(10, 1)
     self.topdict3 = tr_api.removePlayer(1, 10)
     self.topdict4 = tr_api.removePlayer(1, 1)
Beispiel #2
0
 def setUp(self):
     self.topdict = tr_api.listTournaments(None, None)
     self.topdict2 = tr_api.listTournamentPlayers(1)
def main():
    
    while True: # no do while in python :(
        result = None
        command = input(">")
        if len(command) == 0:
            continue
        command = command.split()

        try:
            if command[0].lower() == 'cp':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 2)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.createPlayer(int(command[1]), name)
                table_print(result)
            elif command[0].lower() == 'ct':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 2)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.createTournament(name, int(command[1]))
                table_print(result)
            elif command[0].lower() == 'sp':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 1)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.searchPlayers(name)
                table_print(result)
            elif command[0].lower() == 'ap':
                result = tr_api.addPlayer(int(command[1]),int(command[2]))
                table_print(result)
            elif command[0].lower() == 'rp':
                result = tr_api.removePlayer(int(command[1]),int(command[2]))
                table_print(result)
            elif command[0].lower() == 'lp':
                result = tr_api.listPlayers()
                table_print(result)
            elif command[0].lower() == 'lt':
                result = tr_api.listTournaments(None, None)
                table_print(result)
            elif command[0].lower() == 'ltp':
                result = tr_api.listTournamentPlayers(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'latp':
                result = tr_api.listActiveTournamentPlayers(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'fr':
                result = tr_api.finishRound(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'genpairings':
                result = tr_api.generatePairings(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'gtp':
                result = tr_api.getTournamentPlayer(int(command[1]))
                print(result)
            elif command[0].lower() == 'gp':
                result = tr_api.getPlayer(int(command[1]))
                player_print(result)
            elif command[0].lower() == 'lm':
                result = tr_api.matchList(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'lr':
                result = tr_api.roundList(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'st':
                result = tr_api.startTournament(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'smr':
                result = tr_api.setMatchResults(
                        int(command[1]), int(command[2]), int(command[3]), int(command[4]))
                table_print(result)

            elif command[0].lower() == 'help':
                print_help()
                continue

            elif command[0].lower() == 'exit':
                return

            else:
                print("Invalid command")
                continue
        except ValueError:
            print("Invalid parameter type")
            continue
        except IndexError:
            print("Invalid number of parameters")
            continue
Beispiel #4
0
 def setUp(self):
     if done is False:
         setUpHelper(self)
     self.topdict = tr_api.listTournamentPlayers(1)
     self.topdict2 = tr_api.listTournamentPlayers(2)
     self.topdict3 = tr_api.listTournamentPlayers(12345678910)
 def test_if_players_are_dropped(self):
     tr_api.removePlayer(12, 3)
     self.topdict5 = tr_api.listTournamentPlayers(3)
     self.assertEqual(self.topdict5.get('rows')[0].get('dropped'), 1)