Remove marshal_association utility
This was used only in the now removed V1 API bindings. Change-Id: I51166886e8336d87837dc7f566a19acf7de1c265
This commit is contained in:
parent
7c77bacc40
commit
669c5fdbe9
@ -92,26 +92,6 @@ def find_resource(manager, name_or_id):
|
||||
return matches[0]
|
||||
|
||||
|
||||
def marshal_association(args, resource_dict, assoc_name):
|
||||
"""Marshal resource association into an API request dict.
|
||||
|
||||
Distinguish between 3 cases:
|
||||
|
||||
- when the value in args is present, set the value in dict too,
|
||||
- when the value in args is an empty string, set the value in dict
|
||||
to none,
|
||||
- when the value in args is None, it means the user did not specify
|
||||
it on the command line and it should not be present in the dict
|
||||
(important for update).
|
||||
"""
|
||||
assoc_value = getattr(args, assoc_name, None)
|
||||
if assoc_value == '':
|
||||
resource_dict[assoc_name] = None
|
||||
elif assoc_value:
|
||||
# TODO(jistr): support for selecting resources by name
|
||||
resource_dict[assoc_name] = {'id': assoc_value}
|
||||
|
||||
|
||||
def import_versioned_module(version, submodule=None):
|
||||
module = 'tuskarclient.v%s' % version
|
||||
if submodule:
|
||||
|
@ -49,29 +49,6 @@ class DefineCommandsTest(test_utils.TestCase):
|
||||
return dummy
|
||||
|
||||
|
||||
class MarshalAssociationTest(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(MarshalAssociationTest, self).setUp()
|
||||
self.args = mock.Mock(spec=['rack'])
|
||||
self.dict = {}
|
||||
|
||||
def test_with_id(self):
|
||||
self.args.rack = '10'
|
||||
utils.marshal_association(self.args, self.dict, 'rack')
|
||||
self.assertEqual(self.dict['rack']['id'], '10')
|
||||
|
||||
def test_with_empty_association(self):
|
||||
self.args.rack = ''
|
||||
utils.marshal_association(self.args, self.dict, 'rack')
|
||||
self.assertEqual(self.dict['rack'], None)
|
||||
|
||||
def test_when_unset(self):
|
||||
self.args.rack = None
|
||||
utils.marshal_association(self.args, self.dict, 'rack')
|
||||
self.assertFalse('rack' in self.dict)
|
||||
|
||||
|
||||
class FindResourceTest(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user