diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-08-23 15:11:51 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-08-25 13:54:44 +0800 |
commit | 858f34a8a3bd8949260dc37f87d13864617ad944 (patch) | |
tree | d8574471f1bca5c2721250c3ec6df44adb4e9f7d /utils/test/testapi/opnfv_testapi/tests | |
parent | 737948891836bea1ebc542f7c2b53a23d53e174d (diff) |
update installer under scenario
1. post, add one or more new installers
2. update, replace existed installers as a totality
3. delete, delete one or more installers by name
4. in post&update, if schema is not consistent with ScenarioInstaller model,
BadRequest will be raised(only extra keys will be detected currently)
5. in post, if installer already exist, return Conflict with already exist
message
6. in update, if a installer appears more than once, also return Conflict
with already exist message
Change-Id: I830dba3bcf5f1a9d1c93513b4aae59009f69dc8f
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/tests')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py | 67 |
1 files changed, 58 insertions, 9 deletions
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 9190af580..4f0fad4df 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 @@ -170,6 +170,7 @@ class TestScenarioUpdate(TestScenarioBase): def update_url_fixture(item): def _update_url_fixture(xstep): def wrapper(self, *args, **kwargs): + self.update_url = '{}/{}'.format(self.scenario_url, item) locator = None if item in ['projects', 'owner']: locator = 'installer={}&version={}'.format( @@ -179,9 +180,9 @@ class TestScenarioUpdate(TestScenarioBase): locator = 'installer={}'.format( self.installer) - self.update_url = '{}/{}?{}'.format(self.scenario_url, - item, - locator) + if locator: + self.update_url = '{}?{}'.format(self.update_url, locator) + xstep(self, *args, **kwargs) return wrapper return _update_url_fixture @@ -280,9 +281,8 @@ class TestScenarioUpdate(TestScenarioBase): @update_url_fixture('projects') @update_partial('_update', '_conflict') def test_updateProjects_duplicated(self): - update1 = models.ScenarioProject(project='qtip').format() - update2 = models.ScenarioProject(project='qtip').format() - return [update1, update2] + update = models.ScenarioProject(project='qtip').format() + return [update, update] @update_url_fixture('projects') @update_partial('_update', '_bad_request') @@ -339,9 +339,8 @@ class TestScenarioUpdate(TestScenarioBase): @update_url_fixture('versions') @update_partial('_update', '_conflict') def test_updateVersions_duplicated(self): - update1 = models.ScenarioVersion(version='euphrates').format() - update2 = models.ScenarioVersion(version='euphrates').format() - return [update1, update2] + update = models.ScenarioVersion(version='euphrates').format() + return [update, update] @update_url_fixture('versions') @update_partial('_update', '_bad_request') @@ -360,6 +359,56 @@ class TestScenarioUpdate(TestScenarioBase): versions) return deletes + @update_url_fixture('installers') + @update_partial('_add', '_success') + def test_addInstallers_succ(self): + add = models.ScenarioInstaller(installer='daisy').format() + self.req_d['installers'].append(add) + return [add] + + @update_url_fixture('installers') + @update_partial('_add', '_conflict') + def test_addInstallers_already_exist(self): + add = models.ScenarioInstaller(installer='apex').format() + return [add] + + @update_url_fixture('installers') + @update_partial('_add', '_bad_request') + def test_addInstallers_bad_schema(self): + add = models.ScenarioInstaller(installer='daisy').format() + add['not_exist'] = 'not_exist' + return [add] + + @update_url_fixture('installers') + @update_partial('_update', '_success') + def test_updateInstallers_succ(self): + update = models.ScenarioInstaller(installer='daisy').format() + self.req_d['installers'] = [update] + return [update] + + @update_url_fixture('installers') + @update_partial('_update', '_conflict') + def test_updateInstallers_duplicated(self): + update = models.ScenarioInstaller(installer='daisy').format() + return [update, update] + + @update_url_fixture('installers') + @update_partial('_update', '_bad_request') + def test_updateInstallers_bad_schema(self): + update = models.ScenarioInstaller(installer='daisy').format() + update['not_exist'] = 'not_exist' + return [update] + + @update_url_fixture('installers') + @update_partial('_delete', '_success') + def test_deleteInstallers(self): + deletes = ['apex'] + installers = self.req_d['installers'] + self.req_d['installers'] = filter( + lambda f: f['installer'] != 'apex', + installers) + return deletes + def _add(self, update_req): return self.post_direct_url(self.update_url, update_req) |