-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from remind101/add_local_parameters
Local parameters for python
- Loading branch information
Showing
4 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import unittest | ||
|
||
from stacker.blueprints.base import get_local_parameters | ||
from stacker.exceptions import MissingLocalParameterException | ||
|
||
|
||
class TestLocalParameters(unittest.TestCase): | ||
def test_default_parameter(self): | ||
parameter_def = {'Param1': {'default': 0}} | ||
parameters = {} | ||
|
||
local = get_local_parameters(parameter_def, parameters) | ||
self.assertEquals(local['Param1'], 0) | ||
|
||
def test_missing_required(self): | ||
parameter_def = {'Param1': {'default': 0}, 'Param2': {}} | ||
parameters = {} | ||
|
||
with self.assertRaises(MissingLocalParameterException) as cm: | ||
get_local_parameters(parameter_def, parameters) | ||
|
||
self.assertEquals('Param2', cm.exception.parameter) | ||
|
||
def test_supplied_parameter(self): | ||
parameter_def = {'Param1': {'default': 0}, 'Param2': {}} | ||
parameters = {'Param1': 1, 'Param2': 2} | ||
|
||
local = get_local_parameters(parameter_def, parameters) | ||
self.assertEquals(parameters, local) |