add tests for launchpad validation
Change-Id: I45a227397c4c9df78e52ecf6c74509ffc997d430 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
committed by
Tony Breeds
parent
f58b6b7eb9
commit
287e223534
@@ -64,10 +64,8 @@ def is_a_hash(val):
|
|||||||
return re.search('^[a-f0-9]{40}$', val, re.I) is not None
|
return re.search('^[a-f0-9]{40}$', val, re.I) is not None
|
||||||
|
|
||||||
|
|
||||||
def validate_metadata(deliverable_info, team_data, mk_warning, mk_error):
|
def validate_launchpad(deliverable_info, mk_warning, mk_error):
|
||||||
"""Look at the general metadata in the deliverable file.
|
"Look for the launchpad project"
|
||||||
"""
|
|
||||||
# Look for the launchpad project
|
|
||||||
try:
|
try:
|
||||||
lp_name = deliverable_info['launchpad']
|
lp_name = deliverable_info['launchpad']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -77,6 +75,11 @@ def validate_metadata(deliverable_info, team_data, mk_warning, mk_error):
|
|||||||
if (lp_resp.status_code // 100) == 4:
|
if (lp_resp.status_code // 100) == 4:
|
||||||
mk_error('Launchpad project %s does not exist' % lp_name)
|
mk_error('Launchpad project %s does not exist' % lp_name)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_metadata(deliverable_info, team_data, mk_warning, mk_error):
|
||||||
|
"""Look at the general metadata in the deliverable file.
|
||||||
|
"""
|
||||||
|
|
||||||
# Look for the team name
|
# Look for the team name
|
||||||
if 'team' not in deliverable_info:
|
if 'team' not in deliverable_info:
|
||||||
mk_error('No team name given')
|
mk_error('No team name given')
|
||||||
@@ -372,6 +375,7 @@ def main():
|
|||||||
print('ERROR: {}'.format(msg))
|
print('ERROR: {}'.format(msg))
|
||||||
errors.append('{}: {}'.format(filename, msg))
|
errors.append('{}: {}'.format(filename, msg))
|
||||||
|
|
||||||
|
validate_launchpad(deliverable_info, mk_warning, mk_error)
|
||||||
validate_metadata(
|
validate_metadata(
|
||||||
deliverable_info,
|
deliverable_info,
|
||||||
team_data,
|
team_data,
|
||||||
|
|||||||
0
openstack_releases/tests/__init__.py
Normal file
0
openstack_releases/tests/__init__.py
Normal file
53
openstack_releases/tests/test_validate.py
Normal file
53
openstack_releases/tests/test_validate.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from oslotest import base
|
||||||
|
|
||||||
|
from openstack_releases.cmds import validate
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidateLaunchpad(base.BaseTestCase):
|
||||||
|
|
||||||
|
def test_no_launchpad_name(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_launchpad(
|
||||||
|
{},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_invalid_launchpad_name(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_launchpad(
|
||||||
|
{'launchpad': 'nonsense-name'},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_valid_launchpad_name(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_launchpad(
|
||||||
|
{'launchpad': 'oslo.config'},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
Reference in New Issue
Block a user