Conversation
…Also use part of cli.CliRunner to simulate a cli call and obtain the stout response.
…ic league. Still need to do live scores.
|
Bah, just realized that I could have written: with self.recorder.use_cassette(cassette_name):
with self.cli_runner.isolation() as runner:like with self.recorder.use_cassette(cassette_name) as cassette, self.cli_runner.isolation() as runner:if anyone wants to, I could change it to the latter. |
| soccer.main.get_team_scores(team, time, self.writer, upcoming, use12hour) | ||
| assert self.get_output(runner) == '\nArsenal FC - vs - Crystal Palace FC Sun 17, 08:00\n' | ||
|
|
||
| def test_team_upcoming_games_with_local_time(self): |
There was a problem hiding this comment.
heh just realized this would completely fail in any machine with a different timezone than me 😛
|
@carlosvargas for nested context managers...you can use contextlib.nested |
| 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) |
There was a problem hiding this comment.
do not concatenate BASE_URL and url....use urlparse library
|
@ueg1990 |
|
ah....didnt know that |
|
I wrote some unit tests a while ago using https://github.com/patrys/httmock I manually saved the Never ended up trying to merge them. I think I had forgot about it... I will have a look at all these changes when I get time. Looks interesting 👍 |
This adds some integration tests for the most basic commands by comparing the stdout output after we have parsed it. This is to help prevent changes to formatting, unicode text not displaying, etc.
It uses Betamax to modify
reqestsso that we can save the request body to a file. It will then use this file in any subsequent calls so that the "response" for a specific endpoint is always the same.I'm also using
click.testing.CliRunner.isolationfunction (src) so that I can easily get a hold of the stdout output.