From 181372e923057217a983abe75af63a3ac442b761 Mon Sep 17 00:00:00 2001 From: Duc Truong Date: Mon, 22 Jan 2018 17:58:15 +0000 Subject: [PATCH] Fix broken test cases * add required param 'name' for negative policy, profile and node tests * use real profile for negative node creation test Change-Id: I4eb9a9dbc0a1bdd5e0864c147974cf8e371789c2 --- .gitignore | 17 ++++++++++++++++- .../api/nodes/test_node_create_negative.py | 7 ++++++- .../api/policies/test_policy_create_negative.py | 2 ++ .../api/policies/test_policy_update_negative.py | 13 ++++++++++--- .../policies/test_policy_validate_negative.py | 3 ++- .../profiles/test_profile_create_negative.py | 2 ++ 6 files changed, 38 insertions(+), 6 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 senlin_tempest_plugin/tests/api/nodes/test_node_create_negative.py mode change 100644 => 100755 senlin_tempest_plugin/tests/api/policies/test_policy_create_negative.py mode change 100644 => 100755 senlin_tempest_plugin/tests/api/policies/test_policy_update_negative.py mode change 100644 => 100755 senlin_tempest_plugin/tests/api/profiles/test_profile_create_negative.py diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 829a273..f9df278 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,20 @@ __pycache__ .testrepository -.tox +*~ +*.eggs *.egg-info +*.iml +*.log *.pyc +*.swp +*.swo +.coverage +.coverage.* +.idea +.project +.pydevproject +.testrepository +.tox +.venv +.DS_Store +.stestr diff --git a/senlin_tempest_plugin/tests/api/nodes/test_node_create_negative.py b/senlin_tempest_plugin/tests/api/nodes/test_node_create_negative.py old mode 100644 new mode 100755 index fa7b7f2..c4dbdac --- a/senlin_tempest_plugin/tests/api/nodes/test_node_create_negative.py +++ b/senlin_tempest_plugin/tests/api/nodes/test_node_create_negative.py @@ -102,6 +102,11 @@ class TestNodeCreateNegativeBadRequest(base.BaseSenlinAPITest): class TestNodeCreateNegativeInvalidRequest(base.BaseSenlinAPITest): + def setUp(self): + super(TestNodeCreateNegativeInvalidRequest, self).setUp() + self.profile_id = utils.create_a_profile(self) + self.addCleanup(utils.delete_a_profile, self, self.profile_id) + @decorators.idempotent_id('b109aa66-2a54-493e-8a07-1ea6f20e17ce') def test_node_create_empty_param(self): params = {} @@ -119,7 +124,7 @@ class TestNodeCreateNegativeInvalidRequest(base.BaseSenlinAPITest): def test_node_create_unsupported_param(self): params = { 'node': { - 'profile_id': 'fake_profile', + 'profile_id': self.profile_id, 'name': 'fake_name', 'boo': 'foo' } diff --git a/senlin_tempest_plugin/tests/api/policies/test_policy_create_negative.py b/senlin_tempest_plugin/tests/api/policies/test_policy_create_negative.py old mode 100644 new mode 100755 index e227467..85f81e3 --- a/senlin_tempest_plugin/tests/api/policies/test_policy_create_negative.py +++ b/senlin_tempest_plugin/tests/api/policies/test_policy_create_negative.py @@ -57,6 +57,8 @@ class TestPolicyCreateNegativeBadRequest(base.BaseSenlinAPITest): def test_policy_create_invalid_param(self): params = { 'policy': { + 'name': 'bar', + 'spec': {}, 'boo': 'foo' } } diff --git a/senlin_tempest_plugin/tests/api/policies/test_policy_update_negative.py b/senlin_tempest_plugin/tests/api/policies/test_policy_update_negative.py old mode 100644 new mode 100755 index 201506f..73cca8c --- a/senlin_tempest_plugin/tests/api/policies/test_policy_update_negative.py +++ b/senlin_tempest_plugin/tests/api/policies/test_policy_update_negative.py @@ -35,15 +35,22 @@ class TestPolicyUpdateNegativeNotFound(base.BaseSenlinAPITest): @decorators.attr(type=['negative']) @decorators.idempotent_id('29414add-9cba-4b72-a7bb-36718671dcab') def test_policy_update_policy_invalid_param(self): + params = { + 'policy': { + 'name': 'foo', + 'spec': {}, + 'boo': 'bar' + } + } ex = self.assertRaises(exceptions.BadRequest, self.client.update_obj, 'policies', '5df90d82-9889-4c6f-824c-30272bcfa767', - {'policy': {'spec': {}, 'boo': 'bar'}}) + params) message = ex.resp_body['error']['message'] self.assertEqual( - "Additional properties are not allowed (u'boo' was " - "unexpected)", str(message)) + "Additional properties are not allowed (u'spec', u'boo' " + "were unexpected)", str(message)) @decorators.attr(type=['negative']) @decorators.idempotent_id('bf26ed1e-1d26-4472-b4c8-0bcca1c0a838') diff --git a/senlin_tempest_plugin/tests/api/policies/test_policy_validate_negative.py b/senlin_tempest_plugin/tests/api/policies/test_policy_validate_negative.py index 87d38b1..a877303 100644 --- a/senlin_tempest_plugin/tests/api/policies/test_policy_validate_negative.py +++ b/senlin_tempest_plugin/tests/api/policies/test_policy_validate_negative.py @@ -48,7 +48,8 @@ class TestPolicyValidateNegativeBadRequest(base.BaseSenlinAPITest): message = ex.resp_body['error']['message'] self.assertEqual( - "'spec' is a required property", str(message)) + "Additional properties are not allowed (u'name' was unexpected)", + str(message)) @decorators.attr(type=['negative']) @decorators.idempotent_id('a1c35d93-2d19-4a72-919f-cfd70f5cbf06') diff --git a/senlin_tempest_plugin/tests/api/profiles/test_profile_create_negative.py b/senlin_tempest_plugin/tests/api/profiles/test_profile_create_negative.py old mode 100644 new mode 100755 index 25c2b41..63f3e93 --- a/senlin_tempest_plugin/tests/api/profiles/test_profile_create_negative.py +++ b/senlin_tempest_plugin/tests/api/profiles/test_profile_create_negative.py @@ -74,6 +74,8 @@ class TestProfileCreateNegativeBadRequest(base.BaseSenlinAPITest): def test_profile_create_invalid_param(self): params = { 'profile': { + 'name': 'bar', + 'spec': {}, 'boo': 'foo' } }