From b63b9e5b22bd8c0f614c7ad3bd525138ef0e1ee6 Mon Sep 17 00:00:00 2001 From: Tibor Leupold Date: Mon, 19 Feb 2024 18:45:31 -0800 Subject: [PATCH] Add test for comopnent with custom exception in init --- laces/test/example/components.py | 10 ++++++++++ laces/test/tests/test_views.py | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/laces/test/example/components.py b/laces/test/example/components.py index 220d6ba..9001a9b 100644 --- a/laces/test/example/components.py +++ b/laces/test/example/components.py @@ -228,3 +228,13 @@ def get_context_data( class ServableIntAdderComponent(Component): def __init__(self, number: int) -> None: self.number = 0 + number + + +class CustomException(Exception): + pass + + +@register_servable("with-custom-exception-init") +class ServableWithCustomExceptionInitializerComponent(Component): + def __init__(self) -> None: + raise CustomException diff --git a/laces/test/tests/test_views.py b/laces/test/tests/test_views.py index 9c24429..a124090 100644 --- a/laces/test/tests/test_views.py +++ b/laces/test/tests/test_views.py @@ -164,3 +164,8 @@ def test_get_component_with_non_string_argument(self) -> None: response = self.client.get("/components/int-adder/?number=2") self.assertEqual(response.status_code, HTTPStatus.BAD_REQUEST) + + def test_get_component_with_custom_exception(self) -> None: + response = self.client.get("/components/with-custom-exception-init/") + + self.assertEqual(response.status_code, HTTPStatus.BAD_REQUEST)