Skip to content

Commit

Permalink
Issue #450: unit tests to verify the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Atharva Chauthaiwale authored and jamesls committed Aug 4, 2017
1 parent ad0f04c commit 13ca27a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ def foo():
return {}

return app


@fixture
def sample_app_incompatible_with_cf():
app = Chalice('sample_invalid_cf')

@app.route('/')
def foo_invalid():
return {}

return app
19 changes: 19 additions & 0 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mock

import pytest
import re
from chalice.config import Config
from chalice import package
from chalice import __version__ as chalice_version
Expand Down Expand Up @@ -273,3 +274,21 @@ def test_fails_with_custom_auth(sample_app_with_auth,
app_name='myapp', manage_iam_role=False, iam_role_arn='role-arn')
with pytest.raises(package.UnsupportedFeatureError):
p.generate_sam_template(config)


def test_app_incompatible_with_cf(sample_app_incompatible_with_cf,
mock_swagger_generator,
mock_policy_generator):
p = package.SAMTemplateGenerator(
mock_swagger_generator, mock_policy_generator)
mock_swagger_generator.generate_swagger.return_value = {
'swagger': 'document'
}
config = Config.create(chalice_app=sample_app_incompatible_with_cf,
api_gateway_stage='dev',
app_name='sample_invalid_cf')
template = p.generate_sam_template(config)
check_exp = re.compile(r'[^A-Za-z0-9]+')
events = template['Resources']['APIHandler']['Properties']['Events']
for k in events.keys():
assert not check_exp.search(k)

0 comments on commit 13ca27a

Please sign in to comment.