Merge "Allow methods to be empty and error when not dict"
This commit is contained in:
commit
2502a9f8d1
|
@ -17,6 +17,7 @@ import mock
|
|||
|
||||
from muranopkgcheck.tests import test_validator_helpers as helpers
|
||||
from muranopkgcheck.validators import muranopl
|
||||
from muranopkgcheck import yaml_loader
|
||||
|
||||
MURANOPL_BASE = {
|
||||
'Name': 'Instance',
|
||||
|
@ -119,6 +120,14 @@ class MuranoPlTests(helpers.BaseValidatorTestClass):
|
|||
self.assertIn('Wrong Scope "Wrong"',
|
||||
next(self.g).message)
|
||||
|
||||
def test_methods_list(self):
|
||||
self.g = self.mpl_validator._valid_methods([])
|
||||
self.assertIn('Methods are not a dict',
|
||||
next(self.g).message)
|
||||
|
||||
def test_methods_null(self):
|
||||
self.g = self.mpl_validator._valid_methods(yaml_loader.YamlNull())
|
||||
|
||||
def test_dict_in_body(self):
|
||||
m_dict = deepcopy(MURANOPL_BASE['Methods'])
|
||||
m_dict['foo']['Body'] = {'$a': 'b'}
|
||||
|
|
|
@ -21,6 +21,7 @@ from muranopkgcheck.checkers import yaql_checker
|
|||
from muranopkgcheck import error
|
||||
from muranopkgcheck.i18n import _
|
||||
from muranopkgcheck.validators import base
|
||||
from muranopkgcheck import yaml_loader
|
||||
|
||||
|
||||
SUPPORTED_FORMATS = frozenset(['1.0', '1.1', '1.2', '1.3', '1.4'])
|
||||
|
@ -188,6 +189,11 @@ class MuranoPLValidator(base.YamlValidator):
|
|||
'"{}"').format(fqn), fqn)
|
||||
|
||||
def _valid_methods(self, value):
|
||||
if not isinstance(value, dict):
|
||||
if not isinstance(value, yaml_loader.YamlNull):
|
||||
yield error.report.E046(_('Methods are not a dict'),
|
||||
value)
|
||||
return
|
||||
for method_name, method_data in six.iteritems(value):
|
||||
if not isinstance(method_data, dict):
|
||||
if method_data:
|
||||
|
|
Loading…
Reference in New Issue