Adds binding for PATCH /v2/plans/:plan_uuid

Adds simplest code to PATCH existing Plan.
Adds test for success.

Change-Id: If32374ed93682e21bc5bb34a556e8d22a1340c95
This commit is contained in:
Petr Blaho 2014-08-08 15:11:00 +02:00
parent 7d2e6d6086
commit d6407e2752
2 changed files with 26 additions and 0 deletions

View File

@ -57,3 +57,15 @@ class PlanManagerTest(tutils.TestCase):
self.pm._create.assert_called_with(
'/v2/plans',
{'dummy': 'dummy plan data'})
def test_patch(self):
"""Test patching a plan."""
self.pm._patch = mock.Mock(return_value=['fake_plan'])
self.assertEqual(
self.pm.patch('42', dummy='dummy plan data'),
['fake_plan'])
self.pm._patch.assert_called_with(
'/v2/plans/42',
{'dummy': 'dummy plan data'})

View File

@ -68,3 +68,17 @@ class PlanManager(base.Manager):
:rtype: tuskarclient.v1.plans.Plan
"""
return self._create(self._path(), fields)
def patch(self, plan_uuid, **fields):
"""Patch an existing Plan.
:param plan_uuid: UUID of the Plan.
:type plan_uuid: string
:param fields: A set of key/value pairs representing the Plan.
:type fields: string
:return: A Plan instance or None if its not found.
:rtype: tuskarclient.v2.plans.Plan or None
"""
return self._patch(self._single_path(plan_uuid), fields)