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

Changed autogen_policy default value from True to None #367

Merged
merged 5 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Next Release (TBD)
redeployments of chalice applications and in the CloudFormation template
generated by ``chalice package``
(`#339 <https://github.com/awslabs/chalice/issues/339>`__)
* Fix autogen_policy in config being ignored
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want to make autogen_policy be a code literal in the changelog.

(`#367 <https://github.com/awslabs/chalice/pull/367>`__)


0.9.0
=====
Expand Down
4 changes: 2 additions & 2 deletions chalice/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def local(ctx, port=8000):

@cli.command()
@click.option('--autogen-policy/--no-autogen-policy',
default=True,
default=None,
help='Automatically generate IAM policy for app code.')
@click.option('--profile', help='Override profile at deploy time.')
@click.option('--api-gateway-stage',
Expand All @@ -104,7 +104,7 @@ def local(ctx, port=8000):
@click.pass_context
def deploy(ctx, autogen_policy, profile, api_gateway_stage, stage,
deprecated_api_gateway_stage):
# type: (click.Context, bool, str, str, str, str) -> None
# type: (click.Context, Optional[bool], str, str, str, str) -> None
if api_gateway_stage is not None and \
deprecated_api_gateway_stage is not None:
raise _create_deprecated_stage_error(api_gateway_stage,
Expand Down
7 changes: 4 additions & 3 deletions chalice/cli/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ def create_default_deployer(self, session, prompter):
session=session, prompter=prompter)

def create_config_obj(self, chalice_stage_name=DEFAULT_STAGE_NAME,
autogen_policy=True, api_gateway_stage=None):
# type: (str, bool, Optional[str]) -> Config
autogen_policy=None, api_gateway_stage=None):
# type: (str, Optional[bool], Optional[str]) -> Config
user_provided_params = {} # type: Dict[str, Any]
default_params = {'project_dir': self.project_dir}
default_params = {'project_dir': self.project_dir,
'autogen_policy': True}
try:
config_from_disk = self.load_project_config()
except (OSError, IOError):
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_can_specify_api_gateway_stage(runner, mock_cli_factory,
cli_factory=mock_cli_factory)
assert result.exit_code == 0
mock_cli_factory.create_config_obj.assert_called_with(
autogen_policy=True, chalice_stage_name='dev',
autogen_policy=None, chalice_stage_name='dev',
api_gateway_stage='notdev'
)

Expand Down
19 changes: 19 additions & 0 deletions tests/functional/cli/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ def test_can_create_config_obj(clifactory):
assert isinstance(obj, Config)


def test_can_create_config_obj_with_override_autogen(clifactory):
config = clifactory.create_config_obj(autogen_policy=False)
assert config.autogen_policy is False


def test_config_file_override_autogen_policy(clifactory):
config_file = os.path.join(
clifactory.project_dir, '.chalice', 'config.json')
with open(config_file, 'w') as f:
f.write('{"autogen_policy": false}')
config = clifactory.create_config_obj()
assert config.autogen_policy is False


def test_can_create_config_obj_with_api_gateway_stage(clifactory):
config = clifactory.create_config_obj(api_gateway_stage='custom-stage')
assert config.api_gateway_stage == 'custom-stage'


def test_cant_load_config_obj_with_bad_project(clifactory):
clifactory.project_dir = 'nowhere-asdfasdfasdfas'
with pytest.raises(RuntimeError):
Expand Down