def DeleteOnePlayer(env, resp): ''' DELETE one player from the database. Set all matches with this player in them to show a NULL id for this player now. Delete all matches that now have two null players. ''' # Get fields from the submitted form fields = getFields(env) # Make sure there is a playerid associated with the delete form sent try: playerid = fields['playerid'][0] except KeyError: print 'There is no player id present.' playerid = '' # If the player id is just white space, delete nothing. playerid = playerid.strip() if playerid: # Delete the player from the database tournament.deletePlayer(playerid) clearTournament() # Drop current tournament since player roster has changed else: print 'No playerid to delete.' # 302 redirect back to the player standings headers = [('Location', '/ShowPlayers'), ('Content-type', 'text/plain')] resp('302 REDIRECT', headers) return ['Redirecting']
def test_delete_invalid_player_id(self): """editPlayer() should throw if the player ID is invalid""" with self.assertRaises(LookupError): tournament.deletePlayer(player="0")
def test_option_delete(self): """editPlayer() deletes player""" q = "SELECT * FROM matches ORDER BY id LIMIT 1" r = tools.query(q) s = str(r[0][0]) self.assertEquals(tournament.deletePlayer(player=s), 0)