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
This commit is contained in:
Duc Truong 2018-01-22 17:58:15 +00:00
parent 4e992e2bd3
commit 181372e923
6 changed files with 38 additions and 6 deletions

17
.gitignore vendored Normal file → Executable file
View File

@ -1,5 +1,20 @@
__pycache__ __pycache__
.testrepository .testrepository
.tox *~
*.eggs
*.egg-info *.egg-info
*.iml
*.log
*.pyc *.pyc
*.swp
*.swo
.coverage
.coverage.*
.idea
.project
.pydevproject
.testrepository
.tox
.venv
.DS_Store
.stestr

View File

@ -102,6 +102,11 @@ class TestNodeCreateNegativeBadRequest(base.BaseSenlinAPITest):
class TestNodeCreateNegativeInvalidRequest(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') @decorators.idempotent_id('b109aa66-2a54-493e-8a07-1ea6f20e17ce')
def test_node_create_empty_param(self): def test_node_create_empty_param(self):
params = {} params = {}
@ -119,7 +124,7 @@ class TestNodeCreateNegativeInvalidRequest(base.BaseSenlinAPITest):
def test_node_create_unsupported_param(self): def test_node_create_unsupported_param(self):
params = { params = {
'node': { 'node': {
'profile_id': 'fake_profile', 'profile_id': self.profile_id,
'name': 'fake_name', 'name': 'fake_name',
'boo': 'foo' 'boo': 'foo'
} }

View File

@ -57,6 +57,8 @@ class TestPolicyCreateNegativeBadRequest(base.BaseSenlinAPITest):
def test_policy_create_invalid_param(self): def test_policy_create_invalid_param(self):
params = { params = {
'policy': { 'policy': {
'name': 'bar',
'spec': {},
'boo': 'foo' 'boo': 'foo'
} }
} }

View File

@ -35,15 +35,22 @@ class TestPolicyUpdateNegativeNotFound(base.BaseSenlinAPITest):
@decorators.attr(type=['negative']) @decorators.attr(type=['negative'])
@decorators.idempotent_id('29414add-9cba-4b72-a7bb-36718671dcab') @decorators.idempotent_id('29414add-9cba-4b72-a7bb-36718671dcab')
def test_policy_update_policy_invalid_param(self): def test_policy_update_policy_invalid_param(self):
params = {
'policy': {
'name': 'foo',
'spec': {},
'boo': 'bar'
}
}
ex = self.assertRaises(exceptions.BadRequest, ex = self.assertRaises(exceptions.BadRequest,
self.client.update_obj, 'policies', self.client.update_obj, 'policies',
'5df90d82-9889-4c6f-824c-30272bcfa767', '5df90d82-9889-4c6f-824c-30272bcfa767',
{'policy': {'spec': {}, 'boo': 'bar'}}) params)
message = ex.resp_body['error']['message'] message = ex.resp_body['error']['message']
self.assertEqual( self.assertEqual(
"Additional properties are not allowed (u'boo' was " "Additional properties are not allowed (u'spec', u'boo' "
"unexpected)", str(message)) "were unexpected)", str(message))
@decorators.attr(type=['negative']) @decorators.attr(type=['negative'])
@decorators.idempotent_id('bf26ed1e-1d26-4472-b4c8-0bcca1c0a838') @decorators.idempotent_id('bf26ed1e-1d26-4472-b4c8-0bcca1c0a838')

View File

@ -48,7 +48,8 @@ class TestPolicyValidateNegativeBadRequest(base.BaseSenlinAPITest):
message = ex.resp_body['error']['message'] message = ex.resp_body['error']['message']
self.assertEqual( 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.attr(type=['negative'])
@decorators.idempotent_id('a1c35d93-2d19-4a72-919f-cfd70f5cbf06') @decorators.idempotent_id('a1c35d93-2d19-4a72-919f-cfd70f5cbf06')

View File

@ -74,6 +74,8 @@ class TestProfileCreateNegativeBadRequest(base.BaseSenlinAPITest):
def test_profile_create_invalid_param(self): def test_profile_create_invalid_param(self):
params = { params = {
'profile': { 'profile': {
'name': 'bar',
'spec': {},
'boo': 'foo' 'boo': 'foo'
} }
} }