-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add tests #1
Conversation
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.
I found that the tests were a bit heavy to read :)
@@ -0,0 +1,20 @@ | |||
language: python | |||
python: 2.7 |
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.
You can do better ;)
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.
What do you mean?
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.
It should also work with Py3
tests/test_client.py
Outdated
@@ -0,0 +1,151 @@ | |||
import mock | |||
import pytest | |||
from portier.client import discover_keys, get_verified_email |
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.
nit: separation between imports
tests/test_client.py
Outdated
|
||
assert mocked_requests.get.call_count == 2 | ||
mocked_requests.get.assert_any_call( | ||
"http://broker-url.tld//.well-known/openid-configuration") |
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.
Double slash ?
tests/test_client.py
Outdated
) | ||
keys = discover_keys("http://broker-url.tld/", cache) | ||
|
||
assert isinstance(keys, dict) |
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.
I think that part doesn't have to be in the with
tests/test_client.py
Outdated
|
||
def test_discover_key_raises_a_value_error_if_keys_not_found(): | ||
cache = mock.MagicMock() | ||
cache.get.return_value = None |
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.
Declare an empty_cache
once on top somewhere?
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.
You want me to create a class with a setup phase right?
tests/test_client.py
Outdated
{"kid": "abc", | ||
"e": "KHTPnNouCvwROWeIWQkJiw", | ||
"n": "ZgKgqvEo_GZMamwy293IvA", | ||
"alg": "RS256"}]}, |
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.
I have the feeling that tests could be a lot easier to read if those crazy values would be declared once on top (eg. warm_cache
, TOKEN
, etc...)
tests/test_client.py
Outdated
} | ||
result = get_verified_email("http://broker-url.tld/", | ||
"eyJraWQiOiAiYWJjIn0.foo.bar", | ||
"audience", "issuer", cache) |
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.
Add kwargs names?
Is it better now? |
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.
Yeah! better :)
@leplatrem r?