fix: Catching wikidata errors properly + fixed errors parsing

chrisr3d 2019-10-15 14:41:38 +02:00
parent 8aca19ba68
commit bc0c7c7d7d
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 3 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class TestExpansions(unittest.TestCase):
def misp_modules_post(self, query):
return, "query"), json=query)
def get_errors(self, reponse):
def get_errors(self, response):
data = response.json()
if not isinstance(data, dict):
print(json.dumps(data, indent=2))
@ -136,6 +136,8 @@ class TestExpansions(unittest.TestCase):
response = self.misp_modules_post(query)
self.assertEqual(self.get_values(response), '')
except KeyError:
self.assertEqual(self.get_errors(response), 'Something went wrong, look in the server logs for details')
except Exception:
self.assertEqual(self.get_values(response), 'No additional data found on Wikidata')