add tests for configurable default values for parameters

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2013-09-04 22:11:08 +02:00
parent a4151fee44
commit 1927d4852a
6 changed files with 28 additions and 0 deletions

View file

@ -146,3 +146,10 @@ class TypeTestCase(test.CdistTestCase):
cdist_type = core.CdistType(base_path, '__without_boolean_parameters')
self.assertEqual(cdist_type.boolean_parameters, [])
def test_with_parameter_defaults(self):
base_path = fixtures
cdist_type = core.CdistType(base_path, '__with_parameter_defaults')
self.assertTrue('optional1' in cdist_type.parameter_defaults)
self.assertFalse('optional2' in cdist_type.parameter_defaults)
self.assertEqual(cdist_type.parameter_defaults['optional1'], 'value1')

View file

@ -0,0 +1,2 @@
optional1
optional2

View file

@ -219,6 +219,21 @@ class ArgumentsTestCase(test.CdistTestCase):
self.assertFalse('optional2' in cdist_object.parameters)
self.assertEqual(cdist_object.parameters['optional1'], value)
def test_argument_defaults(self):
type_name = '__argument_defaults'
object_id = 'some-id'
value = 'value1'
argv = [type_name, object_id]
os.environ.update(self.env)
emu = emulator.Emulator(argv)
emu.run()
cdist_type = core.CdistType(self.local.type_path, type_name)
cdist_object = core.CdistObject(cdist_type, self.local.object_path, object_id)
self.assertTrue('optional1' in cdist_object.parameters)
self.assertFalse('optional2' in cdist_object.parameters)
self.assertEqual(cdist_object.parameters['optional1'], value)
class StdinTestCase(test.CdistTestCase):

View file

@ -0,0 +1,2 @@
optional1
optional2