mirror of https://github.com/MISP/PyMISP
Fix flattening, fix python2.7
parent
8dbeec3f96
commit
cd25559c94
|
@ -168,7 +168,11 @@ class PyMISP(object):
|
||||||
for where, errors in response['errors'].items():
|
for where, errors in response['errors'].items():
|
||||||
if isinstance(errors, dict):
|
if isinstance(errors, dict):
|
||||||
for where, msg in errors.items():
|
for where, msg in errors.items():
|
||||||
messages.append('Error in {}: {}'.format(where, msg))
|
if isinstance(msg, list):
|
||||||
|
for m in msg:
|
||||||
|
messages.append('Error in {}: {}'.format(where, m))
|
||||||
|
else:
|
||||||
|
messages.append('Error in {}: {}'.format(where, msg))
|
||||||
else:
|
else:
|
||||||
for e in errors:
|
for e in errors:
|
||||||
if isinstance(e, str):
|
if isinstance(e, str):
|
||||||
|
|
|
@ -101,7 +101,7 @@ class TestOffline(unittest.TestCase):
|
||||||
|
|
||||||
def test_newEvent(self, m):
|
def test_newEvent(self, m):
|
||||||
error_empty_info = {'message': 'The event could not be saved.', 'name': 'Add event failed.', 'errors': {'Event': {'info': ['Info cannot be empty.']}}, 'url': '/events/add'}
|
error_empty_info = {'message': 'The event could not be saved.', 'name': 'Add event failed.', 'errors': {'Event': {'info': ['Info cannot be empty.']}}, 'url': '/events/add'}
|
||||||
error_empty_info_flatten = {'message': 'The event could not be saved.', 'name': 'Add event failed.', 'errors': ["Error in info: ['Info cannot be empty.']"], 'url': '/events/add'}
|
error_empty_info_flatten = {u'message': u'The event could not be saved.', u'name': u'Add event failed.', u'errors': [u"Error in info: Info cannot be empty."], u'url': u'/events/add'}
|
||||||
self.initURI(m)
|
self.initURI(m)
|
||||||
pymisp = PyMISP(self.domain, self.key)
|
pymisp = PyMISP(self.domain, self.key)
|
||||||
with self.assertRaises(pm.api.NewEventError):
|
with self.assertRaises(pm.api.NewEventError):
|
||||||
|
|
Loading…
Reference in New Issue