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 for bespin.amazon.credentials #44
Conversation
Oh python2.6. You so silly. |
tests/amazon/test_credentials.py
Outdated
@@ -33,8 +33,7 @@ | |||
@mock_sts | |||
it "verify_creds ensures account_id matches aws": | |||
credentials = Credentials('us-west-1', 987654321, NotSpecified) | |||
with self.assertRaises(BespinError): | |||
credentials.verify_creds() # 987654321 != 123456789012 | |||
self.assertRaises(BespinError, credentials.verify_creds) # 987654321 != 123456789012 |
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 suggest
with self.fuzzAssertRaisesError(BespinError, "message you expect", kwarg1=1, kwarg2=2):
credentials.verify_creds()
It's defined by delfick_error (https://github.com/delfick/delfick_error/blob/master/delfick_error.py#L143)
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.
Travis didn't like that.
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 can't see delfick_error in setup.py
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's pulled in by delfick-app
tests/amazon/test_credentials.py
Outdated
from bespin.amazon.credentials import Credentials | ||
from bespin.errors import BespinError | ||
from tests.helpers import BespinCase | ||
from input_algorithms.spec_base import NotSpecified |
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'm a bit nitpicky about imports
Usually I split into groups
<bespin imports>
<test specific imports>
<other imports>
Each block has no empty newlines and is ordered by the length of the line, longest line to shortest line.
so here, would be
from bespin.amazon.credentials import Credentials
from bespin.errors import BespinError
from tests.helpers import BespinCase
from input_algorithms.spec_base import NotSpecified
from moto import mock_sts
import os
tests/amazon/test_credentials.py
Outdated
@mock_sts | ||
it "verify_creds ensures account_id matches aws": | ||
credentials = Credentials('us-west-1', 987654321, NotSpecified) | ||
with self.fuzzAssertRaisesError(BespinError, "Please use credentials for the right account", expect=self.account_id, got=amazon_account_id): |
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.
should be fuzzy instead of fuzz
9b35c6c
to
12b90c0
Compare
Would it be better/possible to mock a clone of os.environ for the particular unittests which would modify the environment? |
possibly, should be possible with mock.patch.dict https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.dict |
unittest.mock is only available post python 3.3 |
that's why it's a dep in setup.py https://github.com/delfick/bespin/blob/master/setup.py#L37 |
No description provided.