diff --git a/tuskar/api/controllers/v2/plans.py b/tuskar/api/controllers/v2/plans.py index dbaacf90..3b95e6f7 100644 --- a/tuskar/api/controllers/v2/plans.py +++ b/tuskar/api/controllers/v2/plans.py @@ -114,3 +114,23 @@ class PlansController(rest.RestController): @pecan.expose() def templates(self, plan_uuid): return plan_uuid + + @wsme.validate(models.Plan) + @wsme_pecan.wsexpose(models.Plan, + str, + body=models.Plan, + status_code=201) + def patch(self, plan_uuid, transfer_plan): + """Patches existing plan. + + :param transfer_plan: data submitted by the user + :type transfer_plan: + tuskar.api.controllers.v1.models.Plan + + :return: patched plan + :rtype: tuskar.api.controllers.v1.models.Plan + """ + LOG.debug('Patching plan: %s' % transfer_plan) + + # Package for transfer back to the user + return transfer_plan diff --git a/tuskar/tests/api/controllers/v2/test_plans.py b/tuskar/tests/api/controllers/v2/test_plans.py index 2adfe545..2cc5ad97 100644 --- a/tuskar/tests/api/controllers/v2/test_plans.py +++ b/tuskar/tests/api/controllers/v2/test_plans.py @@ -86,3 +86,16 @@ class PlansTests(base.TestCase): # Verify self.assertEqual(response.status_int, 200) self.assertEqual(result, 'foo') + + def test_patch(self): + # Setup + plan_data = {'name': 'new'} + + # Test + url = URL_PLANS + '/' + 'qwert12345' + response = self.app.patch_json(url, plan_data) + result = response.json + + # Verify + self.assertEqual(response.status_int, 201) + self.assertEqual(result['name'], plan_data['name'])