-
Notifications
You must be signed in to change notification settings - Fork 222
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
Adding integration tests #84
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -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) |
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.
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
reqests
so 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.isolation
function (src) so that I can easily get a hold of the stdout output.