Improve package version validation
Change-Id: Ib9f7ea83ddd5a042010ea8e35f4426939745e17e
This commit is contained in:
parent
88c7813273
commit
3b4dfa537b
|
@ -55,6 +55,11 @@ class ManifestValidatorTests(helpers.BaseValidatorTestClass):
|
|||
self.g = self.mv._valid_type('Shared Library')
|
||||
self.assertIn('Type is invalid "Shared Library"', next(self.g).message)
|
||||
|
||||
def test_incorrect_package_version(self):
|
||||
self.g = self.mv._valid_version('a1.3')
|
||||
self.assertIn('Version format should be compatible with SemVer '
|
||||
'not "a1.3"', next(self.g).message)
|
||||
|
||||
def test_wrong_require_type(self):
|
||||
self.g = self.mv._valid_require([1, 2, 3])
|
||||
self.assertIn('Require is not a dict type', next(self.g).message)
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
|
||||
import os.path
|
||||
|
||||
import semantic_version
|
||||
import six
|
||||
|
||||
from muranopkgcheck import error
|
||||
|
@ -26,7 +28,7 @@ class ManifestValidator(base.YamlValidator):
|
|||
'manifest.yaml$')
|
||||
self.add_checker(self._valid_format, 'Format', False)
|
||||
self.add_checker(self._valid_string, 'Author', False)
|
||||
self.add_checker(self._valid_string, 'Version', False)
|
||||
self.add_checker(self._valid_version, 'Version', False)
|
||||
self.add_checker(self._valid_fullname, 'FullName')
|
||||
self.add_checker(self._valid_string, 'Name', False)
|
||||
self.add_checker(self._valid_classes, 'Classes', False)
|
||||
|
@ -66,6 +68,14 @@ class ManifestValidator(base.YamlValidator):
|
|||
yield error.report.E071('Type is invalid "{0}"'.format(value),
|
||||
value)
|
||||
|
||||
def _valid_version(self, version):
|
||||
try:
|
||||
semantic_version.Version.coerce(str(version))
|
||||
except ValueError:
|
||||
yield error.report.E071('Version format should be compatible with '
|
||||
'SemVer not "{0}"'.format(version),
|
||||
version)
|
||||
|
||||
def _valid_logo_ui_existance(self, ast):
|
||||
if 'Logo' not in ast:
|
||||
yield self._valid_logo('logo.png')
|
||||
|
|
|
@ -7,3 +7,4 @@ PyYAML>=3.1.0 # MIT
|
|||
yaql>=1.1.0 # Apache 2.0 License
|
||||
six>=1.9.0 # MIT
|
||||
stevedore>=1.16.0 # Apache-2.0
|
||||
semantic_version>=2.3.1 # BSD
|
||||
|
|
Loading…
Reference in New Issue