Closed skellet0r closed 4 years ago
I think the most difficult part is that currently the functions return strings with the data one is looking for rather than the JSON data from the API itself.
Along with this issue, #23 should be worked on at the same time.
The primary function is get() which returns the json data from the API, and the other functions are mostly just examples.
Implementing a test suite is in my plan, but I have no experience with that and have other priorities before spending much time figuring it out. It also seems rather difficult to provide coverage across all the data points—I would likely only be able to create tests to ensure the included functions return the expected data.
If you want to help with this, either some kind of testing or additional functions, feel free to submit pull requests against the develop branch.
@toddrob99 I'll definitely start working on something :+1: :smile:
P.S. Thanks for this repo/project, literally saves a lot of people a lot of time, looking forward to seeing it continue to grow.
@Skellet0r, I don't really know what I'm doing with testing, but before you posted this issue, I had created a file to mess around a little bit. If you are working on this, maybe you can use this:
test_schedule.py
#!/usr/bin/env python
# encoding=utf-8
import statsapi
# Get 2008 World Series Game 5 Part 2 from schedule()
ws08g5p2 = statsapi.schedule(date="10/29/2008")
# There should only be one game returned
assert len(ws08g5p2) == 1
# Validate the game data being returned from the schedule endpoint
assert ws08g5p2[0] == {
"game_id": 243847,
"game_datetime": "2008-10-30T00:37:00Z",
"game_date": "2008-10-29",
"game_type": "W",
"status": "Final",
"away_name": "Tampa Bay Rays",
"home_name": "Philadelphia Phillies",
"away_id": 139,
"home_id": 143,
"doubleheader": "N",
"game_num": 1,
"home_probable_pitcher": "Hamels, Cole",
"away_probable_pitcher": "Kazmir, Scott",
"home_pitcher_note": "Hamels will not only attempt to pitch the Phillies to their first World Series title since 1980 Monday against the Rays, but he'll be attempting to do something no other postseason pitcher has ever done -- go 5-0. Hamels is 4-0 with one Division Series win, two NLCS wins and the Game 1 World Series win in which he held the Rays to two runs on five hits over seven innings. In Game 1, Hamels threw 102 pitches, 38 of them changeups. Since 27 of his 66 strikes came off the changeup, that clearly was his most effective pitch.",
"away_pitcher_note": "Kazmir pitched well in Game 1 when he held the Phillies to three runs on six hits in six innings at Tropicana Field, but he took the loss. The left-hander has now pieced together two quality starts in his last two postseason outings -- including Game 5 of the American League Championship Series when he scattered two hits over six scoreless innings, though he did not get the win as the Red Sox erased a 7-0 deficit after Kazmir left the game. Kazmir has been using his slider more lately and the results have been encouraging.",
"away_score": 3,
"home_score": 4,
"current_inning": 9,
"inning_state": "Top",
"winning_team": "Philadelphia Phillies",
"losing_team": "Tampa Bay Rays",
"winning_pitcher": "J.C. Romero",
"losing_pitcher": "J.P. Howell",
"save_pitcher": "Brad Lidge",
"summary": "2008-10-29 - Tampa Bay Rays (3) @ Philadelphia Phillies (4) (Final)",
}
# Get Phillies vs. Mets games in July 2018
games = statsapi.schedule(
start_date="07/01/2018", end_date="07/31/2018", team=143, opponent=121
)
# There should be 4 games
assert len(games) == 4
Addressed in v0.1.5 -- Thank you!
Implementing some sort of testing could help to alleviate issues such as #6 , #7 , #9 , #12 and also completely eliminate the need for Logging debug information #19 as all code will be up to spec.