get_the_plan auto-creates a plan if it doesn't exist
Change-Id: I9bf9d800aeb73ede836bfbd477d38cf927f2085b
This commit is contained in:
parent
7ed35dee84
commit
ab767a61b0
@ -131,6 +131,9 @@ class OvercloudPlan(base.APIDictWrapper):
|
|||||||
plan_list = cls.list(request)
|
plan_list = cls.list(request)
|
||||||
for plan in plan_list:
|
for plan in plan_list:
|
||||||
return plan
|
return plan
|
||||||
|
# if plan doesn't exist, create it
|
||||||
|
plan = cls.create(request, 'overcloud', 'overcloud')
|
||||||
|
return plan
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete(cls, request, plan_id):
|
def delete(cls, request, plan_id):
|
||||||
|
@ -47,6 +47,17 @@ class TuskarAPITests(test.APITestCase):
|
|||||||
|
|
||||||
self.assertIsInstance(ret_val, api.tuskar.OvercloudPlan)
|
self.assertIsInstance(ret_val, api.tuskar.OvercloudPlan)
|
||||||
|
|
||||||
|
def test_plan_get_the_plan(self):
|
||||||
|
plan = self.tuskarclient_plans.first()
|
||||||
|
|
||||||
|
with patch('tuskar_ui.test.test_driver.tuskar_driver.Plan.list',
|
||||||
|
return_value=[]):
|
||||||
|
with patch('tuskar_ui.test.test_driver.tuskar_driver.Plan.create',
|
||||||
|
return_value=plan):
|
||||||
|
ret_val = api.tuskar.OvercloudPlan.get_the_plan(self.request)
|
||||||
|
|
||||||
|
self.assertIsInstance(ret_val, api.tuskar.OvercloudPlan)
|
||||||
|
|
||||||
def test_plan_delete(self):
|
def test_plan_delete(self):
|
||||||
plan = self.tuskarclient_plans.first()
|
plan = self.tuskarclient_plans.first()
|
||||||
api.tuskar.OvercloudPlan.delete(self.request, plan['id'])
|
api.tuskar.OvercloudPlan.delete(self.request, plan['id'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user