summaryrefslogtreecommitdiffstats
path: root/utils/test
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2017-08-28 10:00:47 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-28 10:00:47 +0000
commit06fba1cf6d82d2525ccc662ab31edad597266d73 (patch)
tree9b143ffa1f4e142cd24d78415c725131f4924a16 /utils/test
parent2a46ee4c60e3eeb95311cf406a9bef71d2d66777 (diff)
parent30d7e5ef5091144ea22185bb27c7e3900d7b6a45 (diff)
Merge "update scenario name"
Diffstat (limited to 'utils/test')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py15
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_models.py6
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py17
3 files changed, 37 insertions, 1 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
index 6cdf99ea0..e9c19a7a4 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -114,8 +114,21 @@ class ScenarioGURHandler(GenericScenarioHandler):
self._get_one(query={'name': name})
pass
+ @swagger.operation(nickname="updateScenarioName")
def put(self, name):
- pass
+ """
+ @description: update scenario, only rename is supported currently
+ @param body: fields to be updated
+ @type body: L{ScenarioUpdateRequest}
+ @in body: body
+ @rtype: L{Scenario}
+ @return 200: update success
+ @raise 404: scenario not exist
+ @raise 403: nothing to update
+ """
+ query = {'name': name}
+ db_keys = ['name']
+ self._update(query=query, db_keys=db_keys)
@swagger.operation(nickname="deleteScenarioByName")
def delete(self, name):
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
index c6da76b81..d950ed1d7 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
@@ -167,6 +167,12 @@ class ScenarioChangeOwnerRequest(models.ModelBase):
@swagger.model()
+class ScenarioUpdateRequest(models.ModelBase):
+ def __init__(self, name=None):
+ self.name = name
+
+
+@swagger.model()
class Scenario(models.ModelBase):
"""
@property installers:
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
index 4f0fad4df..1367fc669 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
@@ -179,6 +179,8 @@ class TestScenarioUpdate(TestScenarioBase):
elif item in ['versions']:
locator = 'installer={}'.format(
self.installer)
+ elif item in ['rename']:
+ self.update_url = self.scenario_url
if locator:
self.update_url = '{}?{}'.format(self.update_url, locator)
@@ -409,6 +411,21 @@ class TestScenarioUpdate(TestScenarioBase):
installers)
return deletes
+ @update_url_fixture('rename')
+ @update_partial('_update', '_success')
+ def test_renameScenario(self):
+ new_name = 'new_scenario_name'
+ update = models.ScenarioUpdateRequest(name=new_name)
+ self.req_d['name'] = new_name
+ return update
+
+ @update_url_fixture('rename')
+ @update_partial('_update', '_forbidden')
+ def test_renameScenario_exist(self):
+ new_name = self.req_d['name']
+ update = models.ScenarioUpdateRequest(name=new_name)
+ return update
+
def _add(self, update_req):
return self.post_direct_url(self.update_url, update_req)