Beispiel #1
0
 def test_get_schema_default(self):
     sot = senlin_fields.Name()
     self.assertEqual({
         'type': ['string'],
         'minLength': 1,
         'maxLength': 255
     }, sot.get_schema())
Beispiel #2
0
 def test_get_schema(self):
     sot = senlin_fields.Name(2, 200)
     self.assertEqual({
         'type': ['string'],
         'minLength': 2,
         'maxLength': 200
     }, sot.get_schema())
Beispiel #3
0
    def test_coerce_failed(self):
        obj = mock.Mock()
        sot = senlin_fields.Name()

        ex = self.assertRaises(ValueError,
                               sot.coerce,
                               obj, 'attr', 'value/bad')
        self.assertEqual("The value for the 'attr' (value/bad) contains "
                         "illegal characters.", six.text_type(ex))
Beispiel #4
0
    def test_coerce_failed(self):
        obj = mock.Mock()
        sot = senlin_fields.Name()

        ex = self.assertRaises(ValueError, sot.coerce, obj, 'attr',
                               'value/bad')
        self.assertEqual(
            "The value for the 'attr' (value/bad) contains "
            "illegal characters. It must contain only "
            "alphanumeric or \"_-.~\" characters and must start "
            "with letter.", six.text_type(ex))
Beispiel #5
0
    def test_init(self):
        sot = senlin_fields.Name(2, 200)

        self.assertEqual(2, sot.min_len)
        self.assertEqual(200, sot.max_len)