1
Fork 0

Fix tests by using lower case model name

This commit is contained in:
Parbhat Puri 2020-04-08 12:12:17 +05:30
parent 74ad4a2511
commit adcbf8bd2e
2 changed files with 22 additions and 23 deletions

View file

@ -23,32 +23,32 @@ class TestSnippetLinkHandler:
Test snippet template renders correctly 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) result = SnippetLinkHandler.expand_db_attributes(attrs)
assert result == f'<a href="{advert.url}/{advert.id}">' assert result == f'<a href="{advert.url}/{advert.id}">'
# class TestSnippetEmbedHandler: class TestSnippetEmbedHandler:
# @pytest.mark.django_db @pytest.mark.django_db
# def test_advert_setup_correctly(self, advert): def test_advert_setup_correctly(self, advert):
# assert advert.text == "advert" assert advert.text == "advert"
# assert advert.url == "https://www.example.com" assert advert.url == "https://www.example.com"
# @pytest.mark.django_db @pytest.mark.django_db
# def test_snippet_create_empty_block_on_error(self, advert): def test_snippet_create_empty_block_on_error(self, advert):
# """ """
# Empty block created in case of exception Empty block created in case of exception
# """ """
# result = SnippetEmbedHandler.expand_db_attributes({"id": 0}) result = SnippetEmbedHandler.expand_db_attributes({"id": 0})
# assert result == "" assert result == ""
# @pytest.mark.django_db @pytest.mark.django_db
# def test_snippet_embed_handler_renders(self, advert): def test_snippet_embed_handler_renders(self, advert):
# """ """
# Test snippet template renders correctly 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 = SnippetEmbedHandler.expand_db_attributes(attrs) result = SnippetEmbedHandler.expand_db_attributes(attrs)
# assert result == f'<div>{advert.text}</div>' assert result == f'<div>{advert.text}</div>'

View file

@ -32,8 +32,7 @@ class SnippetLinkHandler(LinkHandler):
snippet_obj = cls.get_instance(attrs) snippet_obj = cls.get_instance(attrs)
template = cls.get_template(attrs) template = cls.get_template(attrs)
return render_to_string(template, {"object": snippet_obj}) return render_to_string(template, {"object": snippet_obj})
except Exception as e: except Exception:
raise e
return "<a>" return "<a>"