Skip to content

Commit

Permalink
Add additional test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesls committed Mar 29, 2017
1 parent 6a13ad2 commit 06b3561
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
17 changes: 15 additions & 2 deletions tests/functional/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ def test_can_zip_recursive_contents(tmpdir):

def test_can_write_recorded_values(tmpdir):
filename = str(tmpdir.join('deployed.json'))
utils.record_deployed_values({'deployed': 'foo'}, filename)
utils.record_deployed_values({'dev': {'deployed': 'foo'}}, filename)
with open(filename, 'r') as f:
assert json.load(f) == {'deployed': 'foo'}
assert json.load(f) == {'dev': {'deployed': 'foo'}}


def test_can_merge_recorded_values(tmpdir):
filename = str(tmpdir.join('deployed.json'))
first = {'dev': {'deployed': 'values'}}
second = {'prod': {'deployed': 'values'}}
utils.record_deployed_values(first, filename)
utils.record_deployed_values(second, filename)
combined = first.copy()
combined.update(second)
with open(filename, 'r') as f:
data = json.load(f)
assert data == combined
21 changes: 20 additions & 1 deletion tests/unit/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from chalice.config import Config
from chalice.config import Config, DeployedResources


def test_config_create_method():
Expand Down Expand Up @@ -53,3 +53,22 @@ def test_user_params_is_optional():
c = Config(config_from_disk={'stage': 'config_from_disk'},
default_params={'stage': 'default_params'})
assert c.stage == 'config_from_disk'


def test_can_create_deployed_resource_from_dict():
d = DeployedResources.from_dict({
'backend': 'api',
'api_handler_arn': 'arn',
'api_handler_name': 'name',
'rest_api_id': 'id',
'api_gateway_stage': 'stage',
'region': 'region',
'chalice_version': '1.0.0',
})
assert d.backend == 'api'
assert d.api_handler_arn == 'arn'
assert d.api_handler_name == 'name'
assert d.rest_api_id == 'id'
assert d.api_gateway_stage == 'stage'
assert d.region == 'region'
assert d.chalice_version == '1.0.0'

0 comments on commit 06b3561

Please sign in to comment.