703
703
self.assertEqual("int() argument must be a string or a number, "
704
704
"not 'list'", six.text_type(ex))
706
def test_str_from_int(self):
707
schema = {'Type': 'String'}
708
p = properties.Property(schema)
709
self.assertEqual('3', p.get_value(3))
711
def test_str_from_bool(self):
712
schema = {'Type': 'String'}
713
p = properties.Property(schema)
714
self.assertEqual('True', p.get_value(True))
706
716
def test_int_from_str_good(self):
707
717
schema = {'Type': 'Integer'}
708
718
p = properties.Property(schema)
1514
1524
props = properties.Properties(schema, {})
1515
1525
self.assertIsNone(props.validate())
1517
def test_bad_data(self):
1518
schema = {'foo': {'Type': 'String'}}
1519
props = properties.Properties(schema, {'foo': 42})
1520
self.assertRaises(exception.StackValidationFailed, props.validate)
1522
1527
def test_unknown_typo(self):
1523
1528
schema = {'foo': {'Type': 'String'}}
1524
1529
props = properties.Properties(schema, {'food': 42})
1525
1530
self.assertRaises(exception.StackValidationFailed, props.validate)
1532
def test_list_instead_string(self):
1533
schema = {'foo': {'Type': 'String'}}
1534
props = properties.Properties(schema, {'foo': ['foo', 'bar']})
1535
ex = self.assertRaises(exception.StackValidationFailed, props.validate)
1536
self.assertEqual('Property error : foo Value must be a string',
1539
def test_dict_instead_string(self):
1540
schema = {'foo': {'Type': 'String'}}
1541
props = properties.Properties(schema, {'foo': {'foo': 'bar'}})
1542
ex = self.assertRaises(exception.StackValidationFailed, props.validate)
1543
self.assertEqual('Property error : foo Value must be a string',
1527
1546
def test_none_string(self):
1528
1547
schema = {'foo': {'Type': 'String'}}
1529
1548
props = properties.Properties(schema, {'foo': None})