Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #22

Closed
skellet0r opened this issue Oct 5, 2019 · 5 comments
Closed

Testing #22

skellet0r opened this issue Oct 5, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request testing Test suite enhancements/fixes

Comments

@skellet0r
Copy link
Contributor

skellet0r commented Oct 5, 2019

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.

@skellet0r
Copy link
Contributor Author

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.

@toddrob99
Copy link
Owner

toddrob99 commented Oct 5, 2019 via email

@skellet0r
Copy link
Contributor Author

@toddrob99 I'll definitely start working on something 👍 😄

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.

@toddrob99 toddrob99 added enhancement New feature or request testing Test suite enhancements/fixes labels Oct 18, 2019
@toddrob99
Copy link
Owner

@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

@toddrob99 toddrob99 mentioned this issue Nov 9, 2019
toddrob99 added a commit that referenced this issue Nov 9, 2019
# v0.1.5
**FIX**:
* Update required params for team_roster endpoint #29
* Leading & trailing slashes not honored in endpoint config #28

**ENHANCE**:
* Testing #22
* Add requirements.txt files
* Clean up code formatting
@toddrob99
Copy link
Owner

Addressed in v0.1.5 -- Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing Test suite enhancements/fixes
Projects
None yet
Development

No branches or pull requests

2 participants