diff options
author | Serena Feng <feng.xiaowei@zte.com.cn> | 2017-08-22 01:42:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-08-22 01:42:46 +0000 |
commit | 69151dce8f4f9bb59c4998fa9e903618265ac0d5 (patch) | |
tree | 7762d4377b0312348de3c2b2780fb3fb7707dcf8 /utils/test/testapi | |
parent | 73ff381c7bb32f13a3d14e96850b84ab37338633 (diff) | |
parent | d36c8831a33f0c91d5eec8817ba835393406d6bd (diff) |
Merge "change scenario owner"
Diffstat (limited to 'utils/test/testapi')
4 files changed, 51 insertions, 4 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) diff --git a/utils/test/testapi/opnfv_testapi/router/url_mappings.py b/utils/test/testapi/opnfv_testapi/router/url_mappings.py index dc3b656a5..9c9556c6b 100644 --- a/utils/test/testapi/opnfv_testapi/router/url_mappings.py +++ b/utils/test/testapi/opnfv_testapi/router/url_mappings.py @@ -60,9 +60,10 @@ mappings = [ scenario_handlers.ScenarioTIsHandler), (r"/api/v1/scenarios/([^/]+)/customs", scenario_handlers.ScenarioCustomsHandler), - (r"/api/v1/scenarios/([^/]+)/projects", scenario_handlers.ScenarioProjectsHandler), + (r"/api/v1/scenarios/([^/]+)/owner", + scenario_handlers.ScenarioOwnerHandler), # static path (r'/(.*\.(css|png|gif|js|html|json|map|woff2|woff|ttf))', 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 8c54e7d74..466caaf13 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 @@ -172,7 +172,7 @@ class TestScenarioUpdate(TestScenarioBase): def _update_url_fixture(xstep): def wrapper(self, *args, **kwargs): locator = None - if item == 'projects': + if item in ['projects', 'owner']: locator = 'installer={}&version={}'.format( self.installer, self.version) @@ -294,6 +294,13 @@ class TestScenarioUpdate(TestScenarioBase): projects) return deletes, scenario + @update_url_fixture('owner') + @update_partial('_update', '_success') + def test_changeOwner(self, scenario): + new_owner = 'new_owner' + scenario['installers'][0]['versions'][0]['owner'] = 'www' + return new_owner, scenario + def _add(self, update_req, new_scenario): return self.post_direct_url(self.update_url, update_req) |