def test_powerview_create_config_must_be_json(self):
'''If present, config must be a json string.'''
sysadmin = Sysadmin()
data_dict = self._make_create_data_dict()
# replace config with non-json string
data_dict['config'] = "I'm not json."
with nosetools.assert_raises(ValidationError) as cm:
toolkit.get_action('powerview_create')(
context={'user': sysadmin['name']},
data_dict=data_dict
)
error_dict = cm.exception.error_dict['config']
nosetools.assert_true("Could not parse as valid JSON"
in error_dict,
"Expected string not in exception message.")
评论列表
文章目录