def test_error_handling(api: NumerAPI): # String instead of Int with pytest.raises(ValueError): api.get_leaderboard("foo") # round that doesn't exist with pytest.raises(ValueError): api.get_leaderboard(-1) # unauthendicated request with pytest.raises(ValueError): # set wrong token api.token = ("foo", "bar") api.submission_id = 1 api.submission_status()
def main(): # set example username and round example_public_id = "somepublicid" example_secret_key = "somesecretkey" # some API calls do not require logging in napi = NumerAPI(verbosity="info") # download current dataset napi.download_current_dataset(unzip=True) # get competitions all_competitions = napi.get_competitions() # get leaderboard for the current round leaderboard = napi.get_leaderboard() # leaderboard for a historic round leaderboard_67 = napi.get_leaderboard(round_num=67) # provide api tokens napi = NumerAPI(example_public_id, example_secret_key) # upload predictions submission_id = napi.upload_predictions("mypredictions.csv") # check submission status napi.submission_status()
def test_get_leaderboard(): api = NumerAPI() lb = api.get_leaderboard(67) assert len(lb) == 1425
def test_get_leaderboard(api: NumerAPI): lb = api.get_leaderboard(67) assert len(lb) == 1425