-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved classes DD(), DL(), DT() and Del() from html/construct.py to ht…
…ml/tags
- Loading branch information
1 parent
a4b9142
commit 53f4b70
Showing
9 changed files
with
144 additions
and
134 deletions.
There are no files selected for viewing
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
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
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
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
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,25 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Module for constructing delete tags <del>.""" | ||
|
||
from ...templates.html.tags import del_tag | ||
|
||
|
||
class Del(object): | ||
"""Class for constructing del tag. | ||
Args: | ||
cite (str): Specifies a URL to a document that explains the reason | ||
why the text was deleted. | ||
datetime (datetime): Specifies the date and time of when the text was | ||
deleted. | ||
.. versionadded:: 0.2.0 | ||
""" | ||
def __init__(self, cite=None, datetime=None, text=None): | ||
self.tag = 'del' | ||
# TODO: If possible, add validation for attribute cite | ||
self.values = {'cite': cite, 'datetime': datetime, 'text': text} | ||
|
||
def construct(self): | ||
"""Returns the constructed del tag <del>.""" | ||
return del_tag.render(self.values) |
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,55 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Module for constructing description tags <dd>, <dl>, <dt>.""" | ||
|
||
from ...templates.html.tags import dd_tag, dl_tag, dt_tag | ||
|
||
|
||
class DD(object): | ||
"""Class for constructing dd tag. | ||
Args: | ||
text (str): Specifies the dd text. (As in <dd>{text}</dd>) | ||
.. versionadded:: 0.2.0 | ||
""" | ||
def __init__(self, text=None): | ||
self.tag = 'dd' | ||
self.values = {'text': text} | ||
|
||
def construct(self): | ||
"""Returns the constructed dd tag <dd></dd>.""" | ||
return dd_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 | ||
""" | ||
def __init__(self, text=None): | ||
self.tag = 'dl' | ||
self.values = {'text': text} | ||
|
||
def construct(self): | ||
"""Returns the constructed dl tag <dl></dl>.""" | ||
return dl_tag.render(self.values) | ||
|
||
|
||
class DT(object): | ||
"""Class for constructing dt tag. | ||
Args: | ||
text (str): Specifies the dt text. (As in <dt>{text}</dt>) | ||
.. versionadded:: 0.2.0 | ||
""" | ||
def __init__(self, text=None): | ||
self.tag = 'dt' | ||
self.values = {'text': text} | ||
|
||
def construct(self): | ||
"""Returns the constructed dt tag <dt></dt>.""" | ||
return dt_tag.render(self.values) |
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,17 @@ | ||
|
||
from ..fixtures import parametrize | ||
|
||
from korona.html.tags import Del | ||
from korona.templates.html.tags import del_tag | ||
|
||
|
||
@parametrize('attributes', [ | ||
({'cite': 'www.abcd.com'}), | ||
({'datetime': '2014-11-15T22:55:03Z'}), | ||
({'datetime': '2015-11-15T22:55:03Z', 'text': 'abcd'}) | ||
]) | ||
def test_construct_del_tag(attributes): | ||
"""Test for validating whether the del tag is constructed correctly or not. | ||
""" | ||
del_ = Del(**attributes) | ||
assert del_.construct() == del_tag.render(attributes) |
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,36 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from ..fixtures import parametrize | ||
|
||
from korona.html.tags import DD, DL, DT | ||
from korona.templates.html.tags import dd_tag, dl_tag, dt_tag | ||
|
||
|
||
@parametrize('attributes', [ | ||
({'text': 'abc'}) | ||
]) | ||
def test_construct_dd_tag(attributes): | ||
"""Test for validating whether the dd tag is constructed correctly or not. | ||
""" | ||
dd = DD(**attributes) | ||
assert dd.construct() == dd_tag.render(attributes) | ||
|
||
|
||
@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) | ||
|
||
|
||
@parametrize('attributes', [ | ||
({'text': 'abc'}) | ||
]) | ||
def test_construct_dt_tag(attributes): | ||
"""Test for validating whether the dt tag is constructed correctly or not. | ||
""" | ||
dt = DT(**attributes) | ||
assert dt.construct() == dt_tag.render(attributes) |
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