From 4bdb06bd9b24bc1e8ac85eac2e4eabc48719ed9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Thu, 27 Apr 2017 15:16:07 +0200 Subject: [PATCH] Fixed error for internal function get_model_from_collection_string. --- openslides/utils/collection.py | 7 +++++-- tests/unit/utils/test_collection.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openslides/utils/collection.py b/openslides/utils/collection.py index 661007d00..6993218b2 100644 --- a/openslides/utils/collection.py +++ b/openslides/utils/collection.py @@ -506,8 +506,11 @@ def get_model_from_collection_string(collection_string): pass else: _models_to_collection_string[get_collection_string()] = model - - return _models_to_collection_string[collection_string] + try: + 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): diff --git a/tests/unit/utils/test_collection.py b/tests/unit/utils/test_collection.py index 065c7683b..9bb292e9b 100644 --- a/tests/unit/utils/test_collection.py +++ b/tests/unit/utils/test_collection.py @@ -58,7 +58,7 @@ class TestGetModelFromCollectionString(TestCase): self.assertEqual(projector_model, Projector) def test_unknown_app(self): - with self.assertRaises(KeyError): + with self.assertRaises(ValueError): collection.get_model_from_collection_string('invalid/model')