Skip to content

Commit

Permalink
Merge pull request #89 from cwendt94/develop
Browse files Browse the repository at this point in the history
add some int test for basketball. Add deploy action
  • Loading branch information
cwendt94 authored Mar 22, 2020
2 parents dd6f3e5 + ce9ca7a commit 74c1131
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/espn-api-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ jobs:
- name: Install dependencies
run: python setup.py install
- name: Test integration
run: python3 setup.py nosetests --tests tests/football/integration/
run: |
python3 setup.py nosetests --tests tests/football/integration/
python3 setup.py nosetests --tests tests/basketball/integration/
27 changes: 27 additions & 0 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python package release
on:
release:
types: [created]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python setup.py install
pip install twine
- name: Build Python package
run: python setup.py sdist bdist_wheel

- name: Twine check
run: twine check dist/*

- name: Publish to PyPI
run: twine upload dist/* -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }}
2 changes: 1 addition & 1 deletion espn_api/basketball/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, data):
self.eligibleSlots = [POSITION_MAP[pos] for pos in json_parsing(data, 'eligibleSlots')]
self.acquisitionType = json_parsing(data, 'acquisitionType')
self.proTeam = PRO_TEAM_MAP[json_parsing(data, 'proTeamId')]
self.injuryStatus = data['playerPoolEntry']['player']['injuryStatus']
self.injuryStatus = json_parsing(data, 'injuryStatus')
self.stats = {}

# add available stats
Expand Down
16 changes: 9 additions & 7 deletions espn_api/basketball/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ def __init__(self, data, member, roster, schedule):
self.division_id = data['divisionId']
self.wins = data['record']['overall']['wins']
self.losses = data['record']['overall']['losses']
self.stats = {STATS_MAP[i]: j for i, j in data['valuesByStat'].items()}
self.owner = 'None'
self.logo_url = ''
self.stats = None
self.standing = data['playoffSeed']
self.final_standing = data['rankCalculatedFinal']
self.roster = []
self.schedule = []

if 'valuesByStat' in data:
self.stats = {STATS_MAP[i]: j for i, j in data['valuesByStat'].items()}
if member:
self.owner = "%s %s" % (member['firstName'],
member['lastName'])
if 'logo' in data:
self.logo_url = data['logo']
else:
self.logo_url = ''
self.standing = data['playoffSeed']
self.final_standing = data['rankCalculatedFinal']
self.roster = []
self.schedule = []

self._fetch_roster(roster)
self._fetch_schedule(schedule)
Expand Down
Empty file added tests/basketball/__init__.py
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions tests/basketball/integration/test_league.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from unittest import TestCase
from espn_api.basketball import League

# Integration test to make sure ESPN's API didnt change
class LeagueTest(TestCase):

def test_league_init(self):
league = League(411647, 2019)

self.assertEqual(league.scoringPeriodId, 178)

def test_league_scoreboard(self):
league = League(411647, 2019)
scores = league.scoreboard()

self.assertEqual(scores[0].home_final_score, 4240.0)
self.assertEqual(scores[0].away_final_score, 2965.0)

def test_past_league(self):
league = League(411647, 2017)

self.assertEqual(league.scoringPeriodId, 170)

def test_past_league_scoreboard(self):
league = League(411647, 2017)
scores = league.scoreboard()

self.assertEqual(scores[0].home_final_score, 4211.0)
self.assertEqual(scores[0].away_final_score, 3548.5)

0 comments on commit 74c1131

Please sign in to comment.