-
Notifications
You must be signed in to change notification settings - Fork 219
Adding integration tests #84
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
Open
carlosvargas
wants to merge
5
commits into
master
Choose a base branch
from
testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e6e8299
Adding testing scaffold.
carlosvargas a90af95
Updating scaffolding so that Betamax uses same session as main file. …
carlosvargas aa6c20e
Adding integration tests for team commands.
carlosvargas 8757973
Adding integration tests for league standings and scores for a specif…
carlosvargas d4cf618
Updating requirements.txt with libraries needed for testing.
carlosvargas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,6 @@ argparse==1.2.1 | |
| click==5.0 | ||
| requests==2.7.0 | ||
| wsgiref==0.1.2 | ||
| betamax==0.6.0 | ||
| betamax-serializers==0.2.0 | ||
| pytest==2.9.1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,10 @@ | |
| LEAGUE_IDS = leagueids.LEAGUE_IDS | ||
| TEAM_NAMES = teamnames.team_names | ||
|
|
||
| session = requests.Session() | ||
| headers = { | ||
| 'X-Auth-Token': '' | ||
| } | ||
|
|
||
| def get_input_key(): | ||
| """Input API key and validate""" | ||
|
|
@@ -41,6 +45,7 @@ def load_config_key(): | |
| try: | ||
| api_token = os.environ['SOCCER_CLI_API_TOKEN'] | ||
| except KeyError: | ||
|
|
||
| home = os.path.expanduser("~") | ||
| config = os.path.join(home, "soccer-cli.ini") | ||
| if not os.path.exists(config): | ||
|
|
@@ -65,7 +70,7 @@ def load_config_key(): | |
|
|
||
| def _get(url): | ||
| """Handles api.football-data.org requests""" | ||
| req = requests.get(BASE_URL+url, headers=headers) | ||
| req = session.get(BASE_URL+url, headers=headers) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do not concatenate BASE_URL and url....use urlparse library |
||
|
|
||
| if req.status_code == requests.codes.ok: | ||
| return req | ||
|
|
@@ -85,7 +90,7 @@ def _get(url): | |
|
|
||
| def get_live_scores(writer, use_12_hour_format): | ||
| """Gets the live scores""" | ||
| req = requests.get(LIVE_URL) | ||
| req = session.get(LIVE_URL) | ||
| if req.status_code == requests.codes.ok: | ||
| scores = req.json() | ||
| if len(scores["games"]) == 0: | ||
|
|
@@ -237,11 +242,9 @@ def list_team_codes(): | |
| help="Save output to a file (only if csv or json option is provided)") | ||
| def main(league, time, standings, team, live, use12hour, players, output_format, output_file, upcoming, lookup, listcodes, apikey): | ||
| """A CLI for live and past football scores from various football leagues""" | ||
| global headers | ||
| headers = { | ||
| 'X-Auth-Token': apikey | ||
| } | ||
| try: | ||
| headers['X-Auth-Token'] = apikey | ||
|
|
||
| if output_format == 'stdout' and output_file: | ||
| raise IncorrectParametersException('Printing output to stdout and ' | ||
| 'saving to a file are mutually exclusive') | ||
|
|
||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "User-Agent": ["python-requests/2.7.0 CPython/2.7.6 Linux/3.4.0+"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Auth-Token": ["f13b85a10d704cbe99e1aeac5e36703e"]}, "method": "GET", "uri": "http://api.football-data.org/alpha/soccerseasons/398/leagueTable"}, "response": {"body": {"string": "{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398/leagueTable/?matchday=34\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"}},\"leagueCaption\":\"Premier League 2015/16\",\"matchday\":34,\"standing\":[{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/338\"}},\"position\":1,\"teamName\":\"Leicester City FC\",\"playedGames\":33,\"points\":72,\"goals\":57,\"goalsAgainst\":31,\"goalDifference\":26,\"wins\":21,\"draws\":9,\"losses\":3,\"home\":{\"goals\":26,\"goalsAgainst\":15,\"wins\":10,\"draws\":5,\"losses\":1},\"away\":{\"goals\":31,\"goalsAgainst\":16,\"wins\":11,\"draws\":4,\"losses\":2}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/73\"}},\"position\":2,\"teamName\":\"Tottenham Hotspur FC\",\"playedGames\":33,\"points\":65,\"goals\":60,\"goalsAgainst\":25,\"goalDifference\":35,\"wins\":18,\"draws\":11,\"losses\":4,\"home\":{\"goals\":33,\"goalsAgainst\":12,\"wins\":10,\"draws\":5,\"losses\":2},\"away\":{\"goals\":27,\"goalsAgainst\":13,\"wins\":8,\"draws\":6,\"losses\":2}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/57\"}},\"position\":3,\"teamName\":\"Arsenal FC\",\"playedGames\":32,\"points\":59,\"goals\":55,\"goalsAgainst\":33,\"goalDifference\":22,\"wins\":17,\"draws\":8,\"losses\":7,\"home\":{\"goals\":23,\"goalsAgainst\":10,\"wins\":9,\"draws\":3,\"losses\":3},\"away\":{\"goals\":32,\"goalsAgainst\":23,\"wins\":8,\"draws\":5,\"losses\":4}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/65\"}},\"position\":4,\"teamName\":\"Manchester City FC\",\"playedGames\":32,\"points\":57,\"goals\":58,\"goalsAgainst\":33,\"goalDifference\":25,\"wins\":17,\"draws\":6,\"losses\":9,\"home\":{\"goals\":41,\"goalsAgainst\":19,\"wins\":11,\"draws\":1,\"losses\":5},\"away\":{\"goals\":17,\"goalsAgainst\":14,\"wins\":6,\"draws\":5,\"losses\":4}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/66\"}},\"position\":5,\"teamName\":\"Manchester United FC\",\"playedGames\":32,\"points\":53,\"goals\":39,\"goalsAgainst\":30,\"goalDifference\":9,\"wins\":15,\"draws\":8,\"losses\":9,\"home\":{\"goals\":20,\"goalsAgainst\":7,\"wins\":9,\"draws\":4,\"losses\":2},\"away\":{\"goals\":19,\"goalsAgainst\":23,\"wins\":6,\"draws\":4,\"losses\":7}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/563\"}},\"position\":6,\"teamName\":\"West Ham United FC\",\"playedGames\":32,\"points\":52,\"goals\":52,\"goalsAgainst\":40,\"goalDifference\":12,\"wins\":13,\"draws\":13,\"losses\":6,\"home\":{\"goals\":27,\"goalsAgainst\":19,\"wins\":7,\"draws\":7,\"losses\":2},\"away\":{\"goals\":25,\"goalsAgainst\":21,\"wins\":6,\"draws\":6,\"losses\":4}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/340\"}},\"position\":7,\"teamName\":\"Southampton FC\",\"playedGames\":33,\"points\":50,\"goals\":44,\"goalsAgainst\":34,\"goalDifference\":10,\"wins\":14,\"draws\":8,\"losses\":11,\"home\":{\"goals\":31,\"goalsAgainst\":19,\"wins\":9,\"draws\":3,\"losses\":5},\"away\":{\"goals\":13,\"goalsAgainst\":15,\"wins\":5,\"draws\":5,\"losses\":6}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/64\"}},\"position\":8,\"teamName\":\"Liverpool FC\",\"playedGames\":31,\"points\":48,\"goals\":50,\"goalsAgainst\":42,\"goalDifference\":8,\"wins\":13,\"draws\":9,\"losses\":9,\"home\":{\"goals\":24,\"goalsAgainst\":19,\"wins\":6,\"draws\":6,\"losses\":3},\"away\":{\"goals\":26,\"goalsAgainst\":23,\"wins\":7,\"draws\":3,\"losses\":6}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/70\"}},\"position\":9,\"teamName\":\"Stoke City FC\",\"playedGames\":33,\"points\":47,\"goals\":37,\"goalsAgainst\":43,\"goalDifference\":-6,\"wins\":13,\"draws\":8,\"losses\":12,\"home\":{\"goals\":19,\"goalsAgainst\":18,\"wins\":7,\"draws\":3,\"losses\":6},\"away\":{\"goals\":18,\"goalsAgainst\":25,\"wins\":6,\"draws\":5,\"losses\":6}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/61\"}},\"position\":10,\"teamName\":\"Chelsea FC\",\"playedGames\":32,\"points\":44,\"goals\":49,\"goalsAgainst\":42,\"goalDifference\":7,\"wins\":11,\"draws\":11,\"losses\":10,\"home\":{\"goals\":29,\"goalsAgainst\":24,\"wins\":5,\"draws\":7,\"losses\":4},\"away\":{\"goals\":20,\"goalsAgainst\":18,\"wins\":6,\"draws\":4,\"losses\":6}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/1044\"}},\"position\":11,\"teamName\":\"AFC Bournemouth\",\"playedGames\":33,\"points\":41,\"goals\":40,\"goalsAgainst\":55,\"goalDifference\":-15,\"wins\":11,\"draws\":8,\"losses\":14,\"home\":{\"goals\":20,\"goalsAgainst\":27,\"wins\":5,\"draws\":4,\"losses\":7},\"away\":{\"goals\":20,\"goalsAgainst\":28,\"wins\":6,\"draws\":4,\"losses\":7}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/72\"}},\"position\":12,\"teamName\":\"Swansea City FC\",\"playedGames\":33,\"points\":40,\"goals\":34,\"goalsAgainst\":42,\"goalDifference\":-8,\"wins\":10,\"draws\":10,\"losses\":13,\"home\":{\"goals\":16,\"goalsAgainst\":18,\"wins\":7,\"draws\":5,\"losses\":5},\"away\":{\"goals\":18,\"goalsAgainst\":24,\"wins\":3,\"draws\":5,\"losses\":8}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/74\"}},\"position\":13,\"teamName\":\"West Bromwich Albion FC\",\"playedGames\":32,\"points\":40,\"goals\":31,\"goalsAgainst\":39,\"goalDifference\":-8,\"wins\":10,\"draws\":10,\"losses\":12,\"home\":{\"goals\":19,\"goalsAgainst\":21,\"wins\":6,\"draws\":4,\"losses\":6},\"away\":{\"goals\":12,\"goalsAgainst\":18,\"wins\":4,\"draws\":6,\"losses\":6}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/62\"}},\"position\":14,\"teamName\":\"Everton FC\",\"playedGames\":31,\"points\":39,\"goals\":52,\"goalsAgainst\":43,\"goalDifference\":9,\"wins\":9,\"draws\":12,\"losses\":10,\"home\":{\"goals\":29,\"goalsAgainst\":28,\"wins\":4,\"draws\":4,\"losses\":8},\"away\":{\"goals\":23,\"goalsAgainst\":15,\"wins\":5,\"draws\":8,\"losses\":2}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/346\"}},\"position\":15,\"teamName\":\"Watford FC\",\"playedGames\":32,\"points\":38,\"goals\":31,\"goalsAgainst\":37,\"goalDifference\":-6,\"wins\":10,\"draws\":8,\"losses\":14,\"home\":{\"goals\":15,\"goalsAgainst\":15,\"wins\":5,\"draws\":5,\"losses\":7},\"away\":{\"goals\":16,\"goalsAgainst\":22,\"wins\":5,\"draws\":3,\"losses\":7}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/354\"}},\"position\":16,\"teamName\":\"Crystal Palace FC\",\"playedGames\":32,\"points\":37,\"goals\":35,\"goalsAgainst\":42,\"goalDifference\":-7,\"wins\":10,\"draws\":7,\"losses\":15,\"home\":{\"goals\":17,\"goalsAgainst\":22,\"wins\":5,\"draws\":2,\"losses\":10},\"away\":{\"goals\":18,\"goalsAgainst\":20,\"wins\":5,\"draws\":5,\"losses\":5}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/68\"}},\"position\":17,\"teamName\":\"Norwich City FC\",\"playedGames\":33,\"points\":31,\"goals\":35,\"goalsAgainst\":57,\"goalDifference\":-22,\"wins\":8,\"draws\":7,\"losses\":18,\"home\":{\"goals\":22,\"goalsAgainst\":24,\"wins\":5,\"draws\":5,\"losses\":6},\"away\":{\"goals\":13,\"goalsAgainst\":33,\"wins\":3,\"draws\":2,\"losses\":12}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/71\"}},\"position\":18,\"teamName\":\"Sunderland AFC\",\"playedGames\":32,\"points\":27,\"goals\":36,\"goalsAgainst\":57,\"goalDifference\":-21,\"wins\":6,\"draws\":9,\"losses\":17,\"home\":{\"goals\":17,\"goalsAgainst\":18,\"wins\":4,\"draws\":5,\"losses\":7},\"away\":{\"goals\":19,\"goalsAgainst\":39,\"wins\":2,\"draws\":4,\"losses\":10}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/67\"}},\"position\":19,\"teamName\":\"Newcastle United FC\",\"playedGames\":32,\"points\":25,\"goals\":32,\"goalsAgainst\":61,\"goalDifference\":-29,\"wins\":6,\"draws\":7,\"losses\":19,\"home\":{\"goals\":22,\"goalsAgainst\":22,\"wins\":4,\"draws\":6,\"losses\":5},\"away\":{\"goals\":10,\"goalsAgainst\":39,\"wins\":2,\"draws\":1,\"losses\":14}},{\"_links\":{\"team\":{\"href\":\"http://api.football-data.org/alpha/teams/58\"}},\"position\":20,\"teamName\":\"Aston Villa FC\",\"playedGames\":33,\"points\":16,\"goals\":23,\"goalsAgainst\":64,\"goalDifference\":-41,\"wins\":3,\"draws\":7,\"losses\":23,\"home\":{\"goals\":12,\"goalsAgainst\":31,\"wins\":2,\"draws\":4,\"losses\":11},\"away\":{\"goals\":11,\"goalsAgainst\":33,\"wins\":1,\"draws\":3,\"losses\":12}}]}", "encoding": "UTF-8"}, "headers": {"x-api-version": ["alpha"], "transfer-encoding": ["chunked"], "x-requestcounter-reset": ["60"], "x-response-control": ["full"], "server": ["nginx/1.2.1"], "x-requests-available": ["49"], "connection": ["keep-alive"], "access-control-allow-credentials": ["true"], "date": ["Fri, 15 Apr 2016 05:39:29 GMT"], "access-control-allow-origin": ["*"], "access-control-allow-methods": ["GET"], "content-type": ["application/json;charset=UTF-8"], "x-authenticated-client": ["Carlos Vargas"]}, "status": {"message": "OK", "code": 200}, "url": "http://api.football-data.org/alpha/soccerseasons/398/leagueTable"}, "recorded_at": "2016-04-15T05:39:37"}], "recorded_with": "betamax/0.6.0"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"http_interactions": [], "recorded_with": "betamax/0.6.0"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "X-Auth-Token": ["f13b85a10d704cbe99e1aeac5e36703e"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "User-Agent": ["python-requests/2.7.0 CPython/2.7.6 Linux/3.4.0+"]}, "method": "GET", "uri": "http://api.football-data.org/alpha/soccerseasons/398/fixtures?timeFrame=p6"}, "response": {"body": {"string": "{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398/fixtures\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"}},\"count\":11,\"fixtures\":[{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146791\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/563\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/57\"}},\"date\":\"2016-04-09T11:45:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"West Ham United FC\",\"awayTeamName\":\"Arsenal FC\",\"result\":{\"goalsHomeTeam\":3,\"goalsAwayTeam\":3}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146788\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/72\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/61\"}},\"date\":\"2016-04-09T14:00:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Swansea City FC\",\"awayTeamName\":\"Chelsea FC\",\"result\":{\"goalsHomeTeam\":1,\"goalsAwayTeam\":0}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146786\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/340\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/67\"}},\"date\":\"2016-04-09T14:00:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Southampton FC\",\"awayTeamName\":\"Newcastle United FC\",\"result\":{\"goalsHomeTeam\":3,\"goalsAwayTeam\":1}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146783\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/354\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/68\"}},\"date\":\"2016-04-09T14:00:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Crystal Palace FC\",\"awayTeamName\":\"Norwich City FC\",\"result\":{\"goalsHomeTeam\":1,\"goalsAwayTeam\":0}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146790\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/346\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/62\"}},\"date\":\"2016-04-09T14:00:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Watford FC\",\"awayTeamName\":\"Everton FC\",\"result\":{\"goalsHomeTeam\":1,\"goalsAwayTeam\":1}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/147085\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/58\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/1044\"}},\"date\":\"2016-04-09T14:00:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Aston Villa FC\",\"awayTeamName\":\"AFC Bournemouth\",\"result\":{\"goalsHomeTeam\":1,\"goalsAwayTeam\":2}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146785\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/65\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/74\"}},\"date\":\"2016-04-09T16:30:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Manchester City FC\",\"awayTeamName\":\"West Bromwich Albion FC\",\"result\":{\"goalsHomeTeam\":2,\"goalsAwayTeam\":1}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146787\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/71\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/338\"}},\"date\":\"2016-04-10T12:30:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Sunderland AFC\",\"awayTeamName\":\"Leicester City FC\",\"result\":{\"goalsHomeTeam\":0,\"goalsAwayTeam\":2}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146789\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/73\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/66\"}},\"date\":\"2016-04-10T15:00:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Tottenham Hotspur FC\",\"awayTeamName\":\"Manchester United FC\",\"result\":{\"goalsHomeTeam\":3,\"goalsAwayTeam\":0}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146784\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/64\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/70\"}},\"date\":\"2016-04-10T15:00:00Z\",\"status\":\"FINISHED\",\"matchday\":33,\"homeTeamName\":\"Liverpool FC\",\"awayTeamName\":\"Stoke City FC\",\"result\":{\"goalsHomeTeam\":4,\"goalsAwayTeam\":1}},{\"_links\":{\"self\":{\"href\":\"http://api.football-data.org/alpha/fixtures/146766\"},\"soccerseason\":{\"href\":\"http://api.football-data.org/alpha/soccerseasons/398\"},\"homeTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/354\"},\"awayTeam\":{\"href\":\"http://api.football-data.org/alpha/teams/62\"}},\"date\":\"2016-04-13T19:00:00Z\",\"status\":\"FINISHED\",\"matchday\":35,\"homeTeamName\":\"Crystal Palace FC\",\"awayTeamName\":\"Everton FC\",\"result\":{\"goalsHomeTeam\":0,\"goalsAwayTeam\":0}}]}", "encoding": "UTF-8"}, "headers": {"x-api-version": ["alpha"], "date": ["Fri, 15 Apr 2016 04:46:28 GMT"], "transfer-encoding": ["chunked"], "x-response-control": ["full"], "server": ["nginx/1.2.1"], "x-requests-available": ["47"], "connection": ["keep-alive"], "access-control-allow-credentials": ["true"], "x-requestcounter-reset": ["38"], "access-control-allow-origin": ["*"], "access-control-allow-methods": ["GET"], "content-type": ["application/json;charset=UTF-8"], "x-authenticated-client": ["Carlos Vargas"]}, "status": {"message": "OK", "code": 200}, "url": "http://api.football-data.org/alpha/soccerseasons/398/fixtures?timeFrame=p6"}, "recorded_at": "2016-04-15T04:46:36"}, {"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Connection": ["keep-alive"], "User-Agent": ["python-requests/2.7.0 CPython/2.7.6 Linux/3.4.0+"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["*/*"], "X-Auth-Token": ["f13b85a10d704cbe99e1aeac5e36703e"]}, "method": "GET", "uri": "http://api.football-data.org/alpha/soccerseasons/398/fixtures?timeFrame=p6"}, "recorded_at": "2016-04-15T04:48:21"}], "recorded_with": "betamax/0.6.0"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"http_interactions": [], "recorded_with": "betamax/0.6.0"} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we using requests.Session?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because Betamax needs to piggy back into the same request session that the application uses. Depending on the configuration, the first time it detects a new request, it will perform it and store the results into a file (called cassettes). Then the second time that request needs to be performed, it will monkeypatch
requestso that instead of hitting the server, it will read from the previously created file.