Skip to content

Commit

Permalink
Add test for comopnent with custom exception in init
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrlpld committed Feb 20, 2024
1 parent 26b507f commit b63b9e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions laces/test/example/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions laces/test/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b63b9e5

Please sign in to comment.