Skip to content

Commit

Permalink
Add more tests;
Browse files Browse the repository at this point in the history
  • Loading branch information
ycliuhw committed Sep 13, 2019
1 parent 4784e5c commit 7f92797
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions charmtools/charms.py
Expand Up @@ -717,6 +717,7 @@ def validate_deployment(charm, linter):
deployment = charm['deployment']
if not isinstance(deployment, dict):
linter.err('deployment: must be a dict of config')
return

known_field_types = {
'type': str,
Expand Down
12 changes: 12 additions & 0 deletions tests/test_charm_proof.py
Expand Up @@ -831,6 +831,18 @@ def test_deployment(self):
validate_deployment(charm, linter)
self.assertFalse(linter.err.called)

def test_invalid_deployment(self):
"""Charm has invalid deployment."""
linter = Mock()
charm = {
'deployment': [],
}
validate_deployment(charm, linter)
self.assertEqual(linter.err.call_count, 1)
linter.err.assert_has_calls([
call('deployment: must be a dict of config'),
], any_order=True)

def test_deployment_unsupported_field(self):
"""Charm has the invalid deployment field."""
linter = Mock()
Expand Down

0 comments on commit 7f92797

Please sign in to comment.