-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #640 from maykinmedia/task/1448-add-bannerplugins-…
…tests [#1448] Add banner plugins tests
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
|
||
from django.test import TestCase | ||
|
||
from open_inwoner.cms.tests import cms_tools | ||
from open_inwoner.utils.test import temp_media_root | ||
from open_inwoner.utils.tests.factories import FilerImageFactory | ||
|
||
from ..cms_plugins import BannerImagePlugin, BannerTextPlugin | ||
|
||
|
||
@temp_media_root() | ||
class TestBannerImage(TestCase): | ||
def test_banner_image_is_rendered_in_plugin(self): | ||
image = FilerImageFactory() | ||
html, context = cms_tools.render_plugin( | ||
BannerImagePlugin, plugin_data={"image": image} | ||
) | ||
self.assertIn(os.path.basename(image.file.name), html) | ||
self.assertIn('<aside class="banner"', html) | ||
|
||
def test_banner_image_with_specific_height(self): | ||
image = FilerImageFactory() | ||
image_height = 40 | ||
html, context = cms_tools.render_plugin( | ||
BannerImagePlugin, | ||
plugin_data={"image": image, "image_height": image_height}, | ||
) | ||
|
||
self.assertIn(os.path.basename(image.file.name), html) | ||
self.assertIn(f'height="{image_height}"', html) | ||
self.assertIn('<aside class="banner"', html) | ||
|
||
|
||
class TestBannerText(TestCase): | ||
def test_banner_text_is_rendered_in_plugin(self): | ||
title = "A title for the banner" | ||
html, context = cms_tools.render_plugin( | ||
BannerTextPlugin, plugin_data={"title": title} | ||
) | ||
|
||
self.assertIn(f'<h1 class="h1">{title} </h1>', html) | ||
|
||
def test_banner_text_with_description_is_rendered_in_plugin(self): | ||
title = "A title for the banner" | ||
description = "Text for description" | ||
html, context = cms_tools.render_plugin( | ||
BannerTextPlugin, plugin_data={"title": title, "description": description} | ||
) | ||
|
||
self.assertIn(f'<h1 class="h1">{title} </h1>', html) | ||
self.assertIn(f'<p class="p">{description}</p>', html) |