Merge "Add DictOfListOfStrings type of field"
This commit is contained in:
commit
3fa3ea7def
|
@ -690,6 +690,11 @@ class ListOfIntegersField(AutoTypedField):
|
|||
AUTO_TYPE = List(fields.Integer())
|
||||
|
||||
|
||||
# FIXME(sbauza): Remove this after oslo.versionedobjects releases it
|
||||
class DictOfListOfStringsField(AutoTypedField):
|
||||
AUTO_TYPE = Dict(List(fields.String()))
|
||||
|
||||
|
||||
# FIXME(danms): Remove this after we convert to oslo.versionedobjects' registry
|
||||
class ObjectField(AutoTypedField):
|
||||
def __init__(self, objtype, **kwargs):
|
||||
|
|
|
@ -802,6 +802,22 @@ class TestListOfSetsOfIntegers(TestField):
|
|||
self.assertEqual('[set([1,2])]', self.field.stringify([set([1, 2])]))
|
||||
|
||||
|
||||
class TestDictOfListOfStrings(TestField):
|
||||
def setUp(self):
|
||||
super(TestDictOfListOfStrings, self).setUp()
|
||||
self.field = fields.DictOfListOfStringsField()
|
||||
self.coerce_good_values = [({'foo': ['1', '2']}, {'foo': ['1', '2']}),
|
||||
({'foo': [1]}, {'foo': ['1']})]
|
||||
self.coerce_bad_values = [{'foo': [None, None]}, 'foo']
|
||||
self.to_primitive_values = [({'foo': ['1', '2']}, {'foo': ['1', '2']})]
|
||||
self.from_primitive_values = [({'foo': ['1', '2']},
|
||||
{'foo': ['1', '2']})]
|
||||
|
||||
def test_stringify(self):
|
||||
self.assertEqual("{foo=['1','2']}",
|
||||
self.field.stringify({'foo': ['1', '2']}))
|
||||
|
||||
|
||||
class TestObject(TestField):
|
||||
def setUp(self):
|
||||
super(TestObject, self).setUp()
|
||||
|
|
Loading…
Reference in New Issue