diff options
author | Serena Feng <feng.xiaowei@zte.com.cn> | 2018-01-15 06:18:32 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-01-15 06:18:32 +0000 |
commit | 62fb9a03e047d70bb15c67d2748ffe377273d0b6 (patch) | |
tree | bed426f6b582efa9b461db9aed6d345aa6952bce /testapi/opnfv_testapi/tests | |
parent | d379980b8999157a77027207d9cda77f87c67e26 (diff) | |
parent | 349609818abcf10cc94088b043f71b5c8bc504a1 (diff) |
Merge "Design the scenario create method"
Diffstat (limited to 'testapi/opnfv_testapi/tests')
-rw-r--r-- | testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py b/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py index 5d1b738..481078d 100644 --- a/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py +++ b/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py @@ -4,6 +4,7 @@ import httplib from opnfv_testapi.common import message import opnfv_testapi.models.scenario_models as sm +from opnfv_testapi.tests.unit import executor from opnfv_testapi.tests.unit.handlers import test_base as base @@ -20,6 +21,7 @@ class TestScenarioBase(base.TestBase): self.req_d = self.load_json('scenario-c1') self.req_2 = self.load_json('scenario-c2') + @executor.mock_valid_lfid() def create_return_name(self, req): _, res = self.create(req) return res.href.split('/')[-1] @@ -45,27 +47,32 @@ class TestScenarioBase(base.TestBase): class TestScenarioCreate(TestScenarioBase): + @executor.mock_valid_lfid() def test_withoutBody(self): (code, body) = self.create() self.assertEqual(code, httplib.BAD_REQUEST) + @executor.mock_valid_lfid() def test_emptyName(self): req_empty = sm.ScenarioCreateRequest('') (code, body) = self.create(req_empty) self.assertEqual(code, httplib.BAD_REQUEST) self.assertIn(message.missing('name'), body) + @executor.mock_valid_lfid() def test_noneName(self): req_none = sm.ScenarioCreateRequest(None) (code, body) = self.create(req_none) self.assertEqual(code, httplib.BAD_REQUEST) self.assertIn(message.missing('name'), body) + @executor.mock_valid_lfid() def test_success(self): (code, body) = self.create_d() self.assertEqual(code, httplib.OK) self.assert_create_body(body) + @executor.mock_valid_lfid() def test_alreadyExist(self): self.create_d() (code, body) = self.create_d() @@ -128,6 +135,7 @@ class TestScenarioDelete(TestScenarioBase): code, body = self.delete('notFound') self.assertEqual(code, httplib.NOT_FOUND) + @executor.mock_valid_lfid() def test_success(self): scenario = self.create_return_name(self.req_d) code, _ = self.delete(scenario) @@ -182,6 +190,7 @@ class TestScenarioUpdate(TestScenarioBase): return wrapper return _update_partial + @executor.mock_valid_lfid() @update_partial('_add', '_success') def test_addScore(self): add = sm.ScenarioScore(date=str(datetime.now()), score='11/12') @@ -193,6 +202,7 @@ class TestScenarioUpdate(TestScenarioBase): return add + @executor.mock_valid_lfid() @update_partial('_add', '_success') def test_addTrustIndicator(self): add = sm.ScenarioTI(date=str(datetime.now()), status='gold') @@ -204,6 +214,7 @@ class TestScenarioUpdate(TestScenarioBase): return add + @executor.mock_valid_lfid() @update_partial('_add', '_success') def test_addCustoms(self): adds = ['odl', 'parser', 'vping_ssh'] @@ -214,6 +225,7 @@ class TestScenarioUpdate(TestScenarioBase): self.locate_project) return adds + @executor.mock_valid_lfid() @update_partial('_update', '_success') def test_updateCustoms(self): updates = ['odl', 'parser', 'vping_ssh'] @@ -225,6 +237,7 @@ class TestScenarioUpdate(TestScenarioBase): return updates + @executor.mock_valid_lfid() @update_partial('_delete', '_success') def test_deleteCustoms(self): deletes = ['vping_ssh'] @@ -236,6 +249,7 @@ class TestScenarioUpdate(TestScenarioBase): return deletes + @executor.mock_valid_lfid() @update_url_fixture('projects') @update_partial('_add', '_success') def test_addProjects_succ(self): @@ -243,12 +257,14 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['installers'][0]['versions'][0]['projects'].append(add) return [add] + @executor.mock_valid_lfid() @update_url_fixture('projects') @update_partial('_add', '_conflict') def test_addProjects_already_exist(self): add = sm.ScenarioProject(project='functest').format() return [add] + @executor.mock_valid_lfid() @update_url_fixture('projects') @update_partial('_add', '_bad_request') def test_addProjects_bad_schema(self): @@ -256,6 +272,7 @@ class TestScenarioUpdate(TestScenarioBase): add['score'] = None return [add] + @executor.mock_valid_lfid() @update_url_fixture('projects') @update_partial('_update', '_success') def test_updateProjects_succ(self): @@ -263,12 +280,14 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['installers'][0]['versions'][0]['projects'] = [update] return [update] + @executor.mock_valid_lfid() @update_url_fixture('projects') @update_partial('_update', '_conflict') def test_updateProjects_duplicated(self): update = sm.ScenarioProject(project='qtip').format() return [update, update] + @executor.mock_valid_lfid() @update_url_fixture('projects') @update_partial('_update', '_bad_request') def test_updateProjects_bad_schema(self): @@ -276,6 +295,7 @@ class TestScenarioUpdate(TestScenarioBase): update['score'] = None return [update] + @executor.mock_valid_lfid() @update_url_fixture('projects') @update_partial('_delete', '_success') def test_deleteProjects(self): @@ -286,6 +306,7 @@ class TestScenarioUpdate(TestScenarioBase): projects) return deletes + @executor.mock_valid_lfid() @update_url_fixture('owner') @update_partial('_update', '_success') def test_changeOwner(self): @@ -294,6 +315,7 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['installers'][0]['versions'][0]['owner'] = new_owner return update + @executor.mock_valid_lfid() @update_url_fixture('versions') @update_partial('_add', '_success') def test_addVersions_succ(self): @@ -301,12 +323,14 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['installers'][0]['versions'].append(add) return [add] + @executor.mock_valid_lfid() @update_url_fixture('versions') @update_partial('_add', '_conflict') def test_addVersions_already_exist(self): add = sm.ScenarioVersion(version='master').format() return [add] + @executor.mock_valid_lfid() @update_url_fixture('versions') @update_partial('_add', '_bad_request') def test_addVersions_bad_schema(self): @@ -314,6 +338,7 @@ class TestScenarioUpdate(TestScenarioBase): add['notexist'] = None return [add] + @executor.mock_valid_lfid() @update_url_fixture('versions') @update_partial('_update', '_success') def test_updateVersions_succ(self): @@ -321,12 +346,14 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['installers'][0]['versions'] = [update] return [update] + @executor.mock_valid_lfid() @update_url_fixture('versions') @update_partial('_update', '_conflict') def test_updateVersions_duplicated(self): update = sm.ScenarioVersion(version='euphrates').format() return [update, update] + @executor.mock_valid_lfid() @update_url_fixture('versions') @update_partial('_update', '_bad_request') def test_updateVersions_bad_schema(self): @@ -334,6 +361,7 @@ class TestScenarioUpdate(TestScenarioBase): update['not_owner'] = 'Iam' return [update] + @executor.mock_valid_lfid() @update_url_fixture('versions') @update_partial('_delete', '_success') def test_deleteVersions(self): @@ -344,6 +372,7 @@ class TestScenarioUpdate(TestScenarioBase): versions) return deletes + @executor.mock_valid_lfid() @update_url_fixture('installers') @update_partial('_add', '_success') def test_addInstallers_succ(self): @@ -351,12 +380,14 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['installers'].append(add) return [add] + @executor.mock_valid_lfid() @update_url_fixture('installers') @update_partial('_add', '_conflict') def test_addInstallers_already_exist(self): add = sm.ScenarioInstaller(installer='apex').format() return [add] + @executor.mock_valid_lfid() @update_url_fixture('installers') @update_partial('_add', '_bad_request') def test_addInstallers_bad_schema(self): @@ -364,6 +395,7 @@ class TestScenarioUpdate(TestScenarioBase): add['not_exist'] = 'not_exist' return [add] + @executor.mock_valid_lfid() @update_url_fixture('installers') @update_partial('_update', '_success') def test_updateInstallers_succ(self): @@ -371,12 +403,14 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['installers'] = [update] return [update] + @executor.mock_valid_lfid() @update_url_fixture('installers') @update_partial('_update', '_conflict') def test_updateInstallers_duplicated(self): update = sm.ScenarioInstaller(installer='daisy').format() return [update, update] + @executor.mock_valid_lfid() @update_url_fixture('installers') @update_partial('_update', '_bad_request') def test_updateInstallers_bad_schema(self): @@ -384,6 +418,7 @@ class TestScenarioUpdate(TestScenarioBase): update['not_exist'] = 'not_exist' return [update] + @executor.mock_valid_lfid() @update_url_fixture('installers') @update_partial('_delete', '_success') def test_deleteInstallers(self): @@ -394,6 +429,7 @@ class TestScenarioUpdate(TestScenarioBase): installers) return deletes + @executor.mock_valid_lfid() @update_url_fixture('rename') @update_partial('_update', '_success') def test_renameScenario(self): @@ -402,6 +438,7 @@ class TestScenarioUpdate(TestScenarioBase): self.req_d['name'] = new_name return update + @executor.mock_valid_lfid() @update_url_fixture('rename') @update_partial('_update', '_forbidden') def test_renameScenario_exist(self): |