Esempio n. 1
0
 def test_validate_spec_invalid_variable(self):
     variables = spec.Variables()
     default = spec.Default(variables=variables, variable='testvariable')
     with self.assertRaisesRegex(
             exceptions.SpecValidationError,
             "Invalid variable referenced by default: 'testvariable'"):
         default.validate_spec(path='test')
Esempio n. 2
0
 def test_get_value_has_default(self):
     variable = spec.Variable(variables=mock.MagicMock(),
                              name='testname',
                              default=spec.Default(
                                  variables=mock.MagicMock(),
                                  value='defaultvalue'))
     self.assertEqual(variable.get_value(), 'defaultvalue')
Esempio n. 3
0
 def test_deserialize(self):
     default = spec.Default(variables=mock.MagicMock())
     default.deserialize(data={
         'value': 'testvalue',
         'variable': 'testvariable'
     })
     self.assertEqual(default.variable, 'testvariable')
     self.assertEqual(default.value, 'testvalue')
Esempio n. 4
0
 def test_validate_spec_both_generator_and_default(self):
     variables = spec.Variables()
     variable = spec.Variable(
         variables=variables,
         name='testname',
         generator='debug',
         default=spec.Default(variables=mock.MagicMock()))
     with self.assertRaisesRegex(
             exceptions.SpecValidationError,
             'Can not provide both "default" and "generator".'):
         variable.validate_spec(path='test')
Esempio n. 5
0
 def test_is_required_has_default_false(self):
     variable = spec.Variable(
         variables=mock.MagicMock(),
         name='testname',
         default=spec.Default(variables=mock.MagicMock()))
     self.assertFalse(variable.is_required())
Esempio n. 6
0
 def test_get_value_variable(self):
     variables = spec.Variables(
         spec.Variable(name='testvariable', value='variablevalue'))
     default = spec.Default(variables=variables, variable='testvariable')
     self.assertEqual(default.get_value(), 'variablevalue')
Esempio n. 7
0
 def test_get_value_value(self):
     default = spec.Default(variables=mock.MagicMock(), value='testvalue')
     self.assertEqual(default.get_value(), 'testvalue')