Skip to content

Commit 0123c9e

Browse files
committed
fixing params bug
1 parent e0fa57a commit 0123c9e

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

tests/test_xmlstats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_teams(self):
8888
self.assertEqual(result[0].team_id, "atlanta-hawks")
8989

9090
def test_team_results(self):
91-
result = self.s.team_results(sport="nba", team_id="atlanta-hawks")
91+
result = self.s.team_results(sport="nba", team_id="atlanta-hawks", event_status="completed", season="2016")
9292
self.assertEqual(result[0].team.team_id, "atlanta-hawks")
9393

9494
def test_blog_example(self):

xmlstats/xmlstats.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def _format_result(self, name, data_str):
3333
object_hook=lambda d: namedtuple(name, d.keys())(*d.values())
3434
)
3535

36-
def _build_url(self, method, sport=None, date=None, id=None, format="json"):
36+
def _build_url(self, method, sport=None,
37+
date=None, id=None, format="json"):
3738
host = "https://erikberg.com/"
3839
path = "/".join(filter(None, (sport, method, date, id)))
3940
url = host + path + "." + format
@@ -99,15 +100,15 @@ def team_results(self, sport, team_id, season=None, opponent=None,
99100
data = self._http_get(
100101
self._build_url(method="results", sport=sport, id=team_id),
101102
params={
102-
season: season,
103-
opponent: opponent,
104-
location_type: location_type,
105-
event_status: event_status,
106-
since: since,
107-
until: until,
108-
last: last,
109-
next: next,
110-
order: order
103+
"season": season,
104+
"opponent": opponent,
105+
"location_type": location_type,
106+
"event_status": event_status,
107+
"since": since,
108+
"until": until,
109+
"last": last,
110+
"next": next,
111+
"order": order
111112
}
112113
)
113114
return self._format_result("TeamResults", data)
@@ -126,8 +127,8 @@ def nba_draft(self, season=None, team_id=None):
126127
data = self._http_get(
127128
self._build_url(sport="nba", method="draft"),
128129
params={
129-
season: season,
130-
team_id: team_id
130+
"season": season,
131+
"team_id": team_id
131132
}
132133
)
133134
return self._format_result("NBADraft", data)
@@ -137,9 +138,11 @@ def nba_draft(self, season=None, team_id=None):
137138

138139
def nba_daily_leaders(self, date=None, sort=None):
139140
data = self._http_get(
140-
self._build_url(sport="nba", method="daily-leaders", date=date),
141+
self._build_url(
142+
sport="nba", method="daily-leaders", date=date
143+
),
141144
params={
142-
sort: sort
145+
"sort": sort
143146
}
144147
)
145148
return self._format_result("NBADailyLeaders", data)
@@ -148,8 +151,8 @@ def nba_team_stats(self, date=None, team_id=None, season_type=None):
148151
data = self._http_get(
149152
self._build_url(sport="nba", method="team-stats", date=date),
150153
params={
151-
season_type: season_type,
152-
team_id: team_id
154+
"season_type": season_type,
155+
"team_id": team_id
153156
}
154157
)
155158
return self._format_result("NBATeamStats", data)

0 commit comments

Comments
 (0)