Skip to content

Commit

Permalink
Add feature opt in test through CLI layer
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesls committed Jan 29, 2019
1 parent 96b42a9 commit ea22664
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/functional/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from chalice.invoke import LambdaInvokeHandler
from chalice.invoke import UnhandledLambdaError
from chalice.awsclient import ReadTimeout
from chalice.deploy.validate import ExperimentalFeatureError


class FakeConfig(object):
Expand Down Expand Up @@ -460,3 +461,24 @@ def test_invoke_does_raise_if_no_function_found(runner, mock_cli_factory):
cli_factory=mock_cli_factory)
assert result.exit_code == 2
assert 'foo' in result.output


def test_error_message_displayed_when_missing_feature_opt_in(runner):
with runner.isolated_filesystem():
cli.create_new_project_skeleton('testproject')
sys.modules.pop('app', None)
with open(os.path.join('testproject', 'app.py'), 'w') as f:
# Rather than pick an existing experimental feature, we're
# manually injecting a feature flag into our app. This ensures
# we don't have to update this test if a feature graduates
# from trial to accepted. The '_features_used' is a "package
# private" var for chalice code.
f.write(
'from chalice import Chalice\n'
'app = Chalice("myapp")\n'
'app._features_used.add("MYTESTFEATURE")\n'
)
os.chdir('testproject')
result = _run_cli_command(runner, cli.package, ['out'])
assert isinstance(result.exception, ExperimentalFeatureError)
assert 'MYTESTFEATURE' in str(result.exception)

0 comments on commit ea22664

Please sign in to comment.