add tests for release notes URL validation
Change-Id: Ic4515b3de4e838ca7d93b0c796e6fde5efbd7667 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
fbeada31bc
commit
bc9ee064a9
@ -85,11 +85,8 @@ def validate_team(deliverable_info, team_data, mk_warning, mk_error):
|
|||||||
deliverable_info['team'])
|
deliverable_info['team'])
|
||||||
|
|
||||||
|
|
||||||
def validate_metadata(deliverable_info, team_data, mk_warning, mk_error):
|
def validate_release_notes(deliverable_info, mk_warning, mk_error):
|
||||||
"""Look at the general metadata in the deliverable file.
|
"Make sure the release notes page exists, if it is specified."
|
||||||
"""
|
|
||||||
|
|
||||||
# Make sure the release notes page exists, if it is specified.
|
|
||||||
if 'release-notes' in deliverable_info:
|
if 'release-notes' in deliverable_info:
|
||||||
notes_link = deliverable_info['release-notes']
|
notes_link = deliverable_info['release-notes']
|
||||||
if isinstance(notes_link, dict):
|
if isinstance(notes_link, dict):
|
||||||
@ -101,8 +98,11 @@ def validate_metadata(deliverable_info, team_data, mk_warning, mk_error):
|
|||||||
if (rn_resp.status_code // 100) != 2:
|
if (rn_resp.status_code // 100) != 2:
|
||||||
mk_error('Could not fetch release notes page %s: %s' %
|
mk_error('Could not fetch release notes page %s: %s' %
|
||||||
(link, rn_resp.status_code))
|
(link, rn_resp.status_code))
|
||||||
else:
|
|
||||||
print('no release-notes specified')
|
|
||||||
|
def validate_metadata(deliverable_info, team_data, mk_warning, mk_error):
|
||||||
|
"""Look at the general metadata in the deliverable file.
|
||||||
|
"""
|
||||||
|
|
||||||
# Determine the deliverable type. Require an explicit value.
|
# Determine the deliverable type. Require an explicit value.
|
||||||
deliverable_type = deliverable_info.get('type')
|
deliverable_type = deliverable_info.get('type')
|
||||||
@ -379,6 +379,7 @@ def main():
|
|||||||
|
|
||||||
validate_launchpad(deliverable_info, mk_warning, mk_error)
|
validate_launchpad(deliverable_info, mk_warning, mk_error)
|
||||||
validate_team(deliverable_info, team_data, mk_warning, mk_error)
|
validate_team(deliverable_info, team_data, mk_warning, mk_error)
|
||||||
|
validate_release_notes(deliverable_info, mk_warning, mk_error)
|
||||||
validate_metadata(
|
validate_metadata(
|
||||||
deliverable_info,
|
deliverable_info,
|
||||||
team_data,
|
team_data,
|
||||||
|
@ -90,3 +90,70 @@ class TestValidateTeam(base.BaseTestCase):
|
|||||||
)
|
)
|
||||||
self.assertEqual(0, len(warnings))
|
self.assertEqual(0, len(warnings))
|
||||||
self.assertEqual(0, len(errors))
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidateReleaseNotes(base.BaseTestCase):
|
||||||
|
|
||||||
|
def test_no_link(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_release_notes(
|
||||||
|
{},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
|
def test_invalid_link(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_release_notes(
|
||||||
|
{'release-notes': 'http://docs.openstack.org/no-such-page'},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_valid_link(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_release_notes(
|
||||||
|
{'release-notes':
|
||||||
|
'http://docs.openstack.org/releasenotes/oslo.config'},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
|
def test_invalid_link_multi(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_release_notes(
|
||||||
|
{
|
||||||
|
'release-notes': {
|
||||||
|
'openstack/releases': 'http://docs.openstack.org/no-such-page',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_valid_link_multi(self):
|
||||||
|
warnings = []
|
||||||
|
errors = []
|
||||||
|
validate.validate_release_notes(
|
||||||
|
{
|
||||||
|
'release-notes': {
|
||||||
|
'openstack/releases': 'http://docs.openstack.org/releasenotes/oslo.config',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
warnings.append,
|
||||||
|
errors.append,
|
||||||
|
)
|
||||||
|
self.assertEqual(0, len(warnings))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
|
Loading…
Reference in New Issue
Block a user