Fixed error for internal function get_model_from_collection_string.

This commit is contained in:
Norman Jäckel 2017-04-27 15:16:07 +02:00
parent 11aacc71b6
commit 4bdb06bd9b
2 changed files with 6 additions and 3 deletions

View File

@ -506,8 +506,11 @@ def get_model_from_collection_string(collection_string):
pass pass
else: else:
_models_to_collection_string[get_collection_string()] = model _models_to_collection_string[get_collection_string()] = model
try:
return _models_to_collection_string[collection_string] model = _models_to_collection_string[collection_string]
except KeyError:
raise ValueError('Invalid message. A valid collection_string is missing.')
return model
def get_single_element_cache_key(collection_string, id): def get_single_element_cache_key(collection_string, id):

View File

@ -58,7 +58,7 @@ class TestGetModelFromCollectionString(TestCase):
self.assertEqual(projector_model, Projector) self.assertEqual(projector_model, Projector)
def test_unknown_app(self): def test_unknown_app(self):
with self.assertRaises(KeyError): with self.assertRaises(ValueError):
collection.get_model_from_collection_string('invalid/model') collection.get_model_from_collection_string('invalid/model')