summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/resources
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2017-08-22 01:42:46 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-22 01:42:46 +0000
commit69151dce8f4f9bb59c4998fa9e903618265ac0d5 (patch)
tree7762d4377b0312348de3c2b2780fb3fb7707dcf8 /utils/test/testapi/opnfv_testapi/resources
parent73ff381c7bb32f13a3d14e96850b84ab37338633 (diff)
parentd36c8831a33f0c91d5eec8817ba835393406d6bd (diff)
Merge "change scenario owner"
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/resources')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py36
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_models.py7
2 files changed, 41 insertions, 2 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
index 09cce7bc5..bd06400b4 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py
@@ -146,6 +146,7 @@ class ScenarioUpdater(object):
('projects', 'post'): self._update_requests_add_projects,
('projects', 'put'): self._update_requests_update_projects,
('projects', 'delete'): self._update_requests_delete_projects,
+ ('owner', 'put'): self._update_requests_change_owner,
}
updates[(item, action)](self.data)
@@ -251,6 +252,11 @@ class ScenarioUpdater(object):
def _update_requests_delete_projects(self, version):
version.projects = self._remove_projects(version.projects)
+ @iter_installers
+ @iter_versions
+ def _update_requests_change_owner(self, version):
+ version.owner = self.body
+
def _filter_installers(self, installers):
return self._filter('installer', installers)
@@ -566,3 +572,33 @@ class ScenarioProjectsHandler(GenericScenarioUpdateHandler):
locators={'scenario': scenario,
'installer': None,
'version': None})
+
+
+class ScenarioOwnerHandler(GenericScenarioUpdateHandler):
+ @swagger.operation(nickname="changeScenarioOwner")
+ def put(self, scenario):
+ """
+ @description: change scenario owner
+ @notes: substitute all projects, delete existed ones with new provides
+ PUT /api/v1/scenarios/<scenario_name>/owner? \
+ installer=<installer_name>& \
+ version=<version_name>
+ @param body: new owner
+ @type body: L{string}
+ @in body: body
+ @param installer: installer type
+ @type installer: L{string}
+ @in installer: query
+ @required installer: True
+ @param version: version
+ @type version: L{string}
+ @in version: query
+ @required version: True
+ @return 200: change owner success.
+ @raise 404: scenario/installer/version not existed
+ """
+ self.do_update('owner',
+ 'put',
+ locators={'scenario': scenario,
+ 'installer': None,
+ 'version': None})
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
index 9f5a07434..7d0770759 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
@@ -74,7 +74,8 @@ class ScenarioVersion(models.ModelBase):
@property projects:
@ptype projects: C{list} of L{ScenarioProject}
"""
- def __init__(self, version=None, projects=None):
+ def __init__(self, owner=None, version=None, projects=None):
+ self.owner = owner
self.version = version
self.projects = list_default(projects)
@@ -83,7 +84,9 @@ class ScenarioVersion(models.ModelBase):
return {'projects': ScenarioProject}
def __eq__(self, other):
- return [self.version == other.version and self._projects_eq(other)]
+ return [self.version == other.version and
+ self.owner == other.owner and
+ self._projects_eq(other)]
def __ne__(self, other):
return not self.__eq__(other)