Skip to content
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

CloudTrail customization fix to use built-in session #496

Merged
merged 4 commits into from
Nov 22, 2013

Conversation

danielgtaylor
Copy link
Contributor

Use default session for AWS CloudTrail customizations and remove custom error handling, which is now handled by the built-in CLI error handler. Fixes an issue where --profile would be ignored during service calls.

Unit tests continue to pass.

…om error handling, which is now handled by the built-in CLI error handler. Fixes an issue where --profile would be ignored during service calls.
# Create the custom command, override its internal method
# so only services are created (and not called)
subscribe = CloudTrailSubscribe(session)
subscribe._call = Mock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have a test without using internal methods?

In general, it's preferable to test through a public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should be able to refactor the service creation code into a public method.

@jamesls
Copy link
Member

jamesls commented Nov 20, 2013

Looks like this is failing CI, mind taking a look? https://travis-ci.org/aws/aws-cli/builds/14277015

@danielgtaylor
Copy link
Contributor Author

Looks like the problem is that I try to create a real session... I'm looking into how to fix this.

@jamesls
Copy link
Member

jamesls commented Nov 21, 2013

I would encourage you to check out tests.unit.BaseAWSCommandParamsTest as an example for how to handle this.

Also I think we should have at least a test that runs the high level command through CLIDriver, e.g. aws cloudtrail create-subscription --profile foo ... and ensures that that proper session profile is used. BaseAWSCommandParamsTest.run_cmd should be able to do most of the heavy lifting.

You might also want to check out the test_clidriver as their are profile related tests you can probably use.

…he entire pipeline from start to finish via clidriver.
@danielgtaylor
Copy link
Contributor Author

@jamesls here is another attempt which uses clidriver to test from commandline arguments all the way through calling the commands with the right session. Let me know what you think.

# future, but for now we just grab that value out of the real
# os.environ so the patched os.environ has this data and
# the CLI works.
self.environ = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like duplicate code from tests/unit/__init__.py. Was there a reason we can't just use that code?

…nd prevent shadowing self in the mocked method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants