From 497b6522ee761ce4cb51804209b92607637c896d Mon Sep 17 00:00:00 2001 From: Petr Blaho Date: Wed, 30 Jul 2014 16:36:52 +0200 Subject: [PATCH] Adds PATCH /v2/plans/:plan_uuid endpoint This patch adds hollow PATCH /v2/plans/:plan_uuid endpoint which returns only dummy response. Logic to manipulate real data will be added later. Change-Id: Ia6b14ccc0834f833560dab2d2b188ea90dea1807 Implements: blueprint tripleo-juno-tuskar-plan-rest-api --- tuskar/api/controllers/v2/plans.py | 20 +++++++++++++++++++ tuskar/tests/api/controllers/v2/test_plans.py | 13 ++++++++++++ 2 files changed, 33 insertions(+) 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'])