def setUp(self): super(TestSort, self).setUp() self.keys = ['key1', 'key2', 'key3'] self.field = senlin_fields.Sort(valid_keys=self.keys) self.coerce_good_values = [ ('key1', 'key1'), # single key ('key1,key2', 'key1,key2'), # multi keys ('key1:asc', 'key1:asc'), # key with dir ('key2:desc', 'key2:desc'), # key with different dir ('key1,key2:asc', 'key1,key2:asc'), # mixed case ] self.coerce_bad_values = [ 'foo', # unknown key ':desc', # unspecified key 'key1:up', # unsupported dir 'key1,key2:up', # unsupported dir 'foo,key2', # unknown key 'key2,:asc', # unspecified key 'key2,:desc', # unspecified key 'key1,', # missing key ',key2', # missing key ] self.to_primitive_values = self.coerce_good_values[0:1] self.from_primitive_values = self.coerce_good_values[0:1]
def test_init(self): keys = ['foo', 'bar'] sot = senlin_fields.Sort(valid_keys=keys) self.assertEqual(keys, sot.valid_keys)