Skip to content

Commit

Permalink
Added DL() class for constructing <dl></dl> tag; Added tests for the …
Browse files Browse the repository at this point in the history
…same
  • Loading branch information
bharadwajyarlagadda committed Sep 2, 2016
1 parent d80e510 commit 97d3485
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
20 changes: 19 additions & 1 deletion korona/html/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
del_tag,
details_tag,
dialog_tag,
div_tag
div_tag,
dl_tag
)

RECTANGLE_SHAPE_COORDINATES = 4
Expand Down Expand Up @@ -884,3 +885,20 @@ def __init__(self, align=None, text=None):
def construct(self):
"""Returns the constructed div tag <div>."""
return div_tag.render(self.values)


class DL(object):
"""Class for constructing dl tag.
Args:
text (str): Specifies the dl text. (As in <dl>{text}</dl>)
.. versionadded:: 0.2.0-alpha
"""
def __init__(self, text=None):
self.tag = 'dl'
self.values = {'text': text}

def construct(self):
"""Returns the constructed dl tag <dl>."""
return dl_tag.render(self.values)
16 changes: 14 additions & 2 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
Del,
Details,
Dialog,
Div
Div,
DL
)
from korona.templates.html import (
anchor_tag,
Expand All @@ -42,7 +43,8 @@
del_tag,
details_tag,
dialog_tag,
div_tag
div_tag,
dl_tag
)
from korona.lib.utils import validate_tag

Expand Down Expand Up @@ -594,3 +596,13 @@ def test_construct_div_tag_error(attributes, exception, error_msg):
Div(**attributes)

assert error_msg in str(exc)


@parametrize('attributes', [
({'text': 'abc'})
])
def test_construct_dl_tag(attributes):
"""Test for validating whether the dl tag is constructed correctly or not.
"""
dl = DL(**attributes)
assert dl.construct() == dl_tag.render(attributes)

0 comments on commit 97d3485

Please sign in to comment.