add tests for validating the deliverable type
Change-Id: I54ebbf160f196ed8b0ba5d1cfabd9e6df27a4e8f Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
bc9ee064a9
commit
4584fe5f13
@ -100,11 +100,8 @@ def validate_release_notes(deliverable_info, mk_warning, mk_error):
|
||||
(link, rn_resp.status_code))
|
||||
|
||||
|
||||
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.
|
||||
def validate_type(deliverable_info, mk_warning, mk_error):
|
||||
"Determine the deliverable type. Require an explicit value."
|
||||
deliverable_type = deliverable_info.get('type')
|
||||
if not deliverable_type:
|
||||
mk_error(
|
||||
@ -380,12 +377,7 @@ def main():
|
||||
validate_launchpad(deliverable_info, 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(
|
||||
deliverable_info,
|
||||
team_data,
|
||||
mk_warning,
|
||||
mk_error,
|
||||
)
|
||||
validate_type(deliverable_info, mk_warning, mk_error)
|
||||
validate_releases(
|
||||
deliverable_info,
|
||||
zuul_layout,
|
||||
|
@ -157,3 +157,39 @@ class TestValidateReleaseNotes(base.BaseTestCase):
|
||||
)
|
||||
self.assertEqual(0, len(warnings))
|
||||
self.assertEqual(0, len(errors))
|
||||
|
||||
|
||||
class TestValidateDeliverableType(base.BaseTestCase):
|
||||
|
||||
def test_no_type(self):
|
||||
warnings = []
|
||||
errors = []
|
||||
validate.validate_type(
|
||||
{},
|
||||
warnings.append,
|
||||
errors.append,
|
||||
)
|
||||
self.assertEqual(0, len(warnings))
|
||||
self.assertEqual(1, len(errors))
|
||||
|
||||
def test_invalid_type(self):
|
||||
warnings = []
|
||||
errors = []
|
||||
validate.validate_type(
|
||||
{'type': 'not-valid'},
|
||||
warnings.append,
|
||||
errors.append,
|
||||
)
|
||||
self.assertEqual(0, len(warnings))
|
||||
self.assertEqual(1, len(errors))
|
||||
|
||||
def test_valid_type(self):
|
||||
warnings = []
|
||||
errors = []
|
||||
validate.validate_type(
|
||||
{'type': 'library'},
|
||||
warnings.append,
|
||||
errors.append,
|
||||
)
|
||||
self.assertEqual(0, len(warnings))
|
||||
self.assertEqual(0, len(errors))
|
||||
|
Loading…
Reference in New Issue
Block a user