diff --git a/tests/test_snippet_handlers.py b/tests/test_snippet_handlers.py index 456d1bf..d6d0693 100644 --- a/tests/test_snippet_handlers.py +++ b/tests/test_snippet_handlers.py @@ -23,32 +23,32 @@ class TestSnippetLinkHandler: Test snippet template renders correctly """ - attrs = {"id": 1, "data-app-name": "testapp", "data-model-name": "Advert"} + attrs = {"id": 1, "data-app-name": "testapp", "data-model-name": "advert"} result = SnippetLinkHandler.expand_db_attributes(attrs) assert result == f'' -# class TestSnippetEmbedHandler: -# @pytest.mark.django_db -# def test_advert_setup_correctly(self, advert): -# assert advert.text == "advert" -# assert advert.url == "https://www.example.com" +class TestSnippetEmbedHandler: + @pytest.mark.django_db + def test_advert_setup_correctly(self, advert): + assert advert.text == "advert" + assert advert.url == "https://www.example.com" -# @pytest.mark.django_db -# def test_snippet_create_empty_block_on_error(self, advert): -# """ -# Empty block created in case of exception -# """ + @pytest.mark.django_db + def test_snippet_create_empty_block_on_error(self, advert): + """ + Empty block created in case of exception + """ -# result = SnippetEmbedHandler.expand_db_attributes({"id": 0}) -# assert result == "" + result = SnippetEmbedHandler.expand_db_attributes({"id": 0}) + assert result == "" -# @pytest.mark.django_db -# def test_snippet_embed_handler_renders(self, advert): -# """ -# Test snippet template renders correctly -# """ + @pytest.mark.django_db + def test_snippet_embed_handler_renders(self, advert): + """ + Test snippet template renders correctly + """ -# attrs = {"id": 1, "data-app-name": "testapp", "data-model-name": "Advert"} -# result = SnippetEmbedHandler.expand_db_attributes(attrs) -# assert result == f'
{advert.text}
' + attrs = {"id": 1, "data-app-name": "testapp", "data-model-name": "advert"} + result = SnippetEmbedHandler.expand_db_attributes(attrs) + assert result == f'
{advert.text}
' diff --git a/wagtail_draftail_snippet/richtext.py b/wagtail_draftail_snippet/richtext.py index 1c9a6d7..5320403 100644 --- a/wagtail_draftail_snippet/richtext.py +++ b/wagtail_draftail_snippet/richtext.py @@ -32,8 +32,7 @@ class SnippetLinkHandler(LinkHandler): snippet_obj = cls.get_instance(attrs) template = cls.get_template(attrs) return render_to_string(template, {"object": snippet_obj}) - except Exception as e: - raise e + except Exception: return "
"