1
Fork 0

Comment Embed Handler tests

This commit is contained in:
Parbhat Puri 2020-04-08 11:54:26 +05:30
parent b8c665c08c
commit d2b3b435f0

View file

@ -28,27 +28,27 @@ class TestSnippetLinkHandler:
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>'