Skip to content
Permalink
Browse files
Merge pull request #215 from getnikola/move-back-disable-test
Move microdata and publication list tests back to test folder.
  • Loading branch information
Kwpolska committed Mar 11, 2017
2 parents 5741140 + a6e4785 commit b357cc963dbedb773f840fa63b35ce19fcefdae5
@@ -31,42 +31,50 @@ def test_itemprop(self):
# <p><span itemprop="name">Test</span></p>
self.sample = ':itemprop:`Test <name>`'
self.basic_test()
self.assertHTMLContains("span", attributes={"itemprop": "name"},
text="Test")
self.assertHTMLContains(
"span", attributes={"itemprop": "name"},
text="Test")
self.assertHTMLContains("p")

def test_itemprop_image(self):
# the result should be
# <img itemprop="photo" src="apple-pie.jpg" />
self.sample = ":itemprop:`<photo|apple-pie.jpg|img>`"
self.basic_test()
self.assertHTMLContains("img", attributes={"itemprop": "photo", "src": "apple-pie.jpg"},
text="")
self.assertHTMLContains(
"img", attributes={"itemprop": "photo", "src": "apple-pie.jpg"},
text="")
self.assertHTMLContains("p")

def test_itemprop_time(self):
# the result should be
# <time datetime="PT30M" itemprop="prepTime">30 min</time>
self.sample = ":itemprop:`30 min <prepTime|PT30M|time>`"
self.basic_test()
self.assertHTMLContains("time", attributes={"itemprop": "prepTime", "datetime": "PT30M"},
text="30 min")
self.assertHTMLContains(
"time", attributes={"itemprop": "prepTime", "datetime": "PT30M"},
text="30 min")
self.assertHTMLContains("p")

def test_itemprop_meta(self):
# the result should be
# <meta itemprop="datePublished" content="2009-05-08">May 8, 2009
expected = (
'<p>'
'<meta content="2009-05-08" itemprop="datePublished" /> May 8, 2009'
'<meta content="2009-05-08" itemprop='
'"datePublished" /> May 8, 2009'
'</p>\n'
)
self.sample = ":itemprop:`<datePublished|2009-05-08|meta>` May 8, 2009"
self.basic_test()
self.assertHTMLContains("meta", attributes={"itemprop": "datePublished", "content": "2009-05-08"},
text="")
self.assertHTMLContains(
"meta",
attributes={"itemprop": "datePublished", "content": "2009-05-08"},
text="")
self.assertHTMLContains("p")
self.assertEqual(self.html.replace('\n', '').strip(), expected.replace('\n', '').strip())
self.assertEqual(
self.html.replace('\n', '').strip(),
expected.replace('\n', '').strip())


class ItemPropUrlTestCase(ReSTExtensionTestCase):
@@ -87,8 +95,9 @@ def test_itemprop_url(self):
# <p><a href="http://somewhere/" itemprop="url">Test</a></p>
self.sample = ':itemprop:`Test <url:http://somewhere/>`'
self.basic_test()
self.assertHTMLContains("a", attributes={"itemprop": "url", "href": "http://somewhere/"},
text="Test")
self.assertHTMLContains(
"a", attributes={"itemprop": "url", "href": "http://somewhere/"},
text="Test")
self.assertHTMLContains("p")


@@ -115,8 +124,12 @@ def test_itemscope(self):
My name is John Doe
"""
self.basic_test()
self.assertHTMLContains("div", attributes={"itemscope": "", "itemtype": "http://data-vocabulary.org/Person"},
text="My name is John Doe")
self.assertHTMLContains(
"div",
attributes={
"itemscope": "True",
"itemtype": "http://data-vocabulary.org/Person"},
text="My name is John Doe")

def test_itemscope_class(self):
# the result should be
@@ -129,11 +142,12 @@ def test_itemscope_class(self):
My name is John Doe
"""
self.basic_test()
self.assertHTMLContains("div", attributes={
"itemscope": "",
"class": "person-scope",
"itemtype": "http://data-vocabulary.org/Person"},
text="My name is John Doe")
self.assertHTMLContains(
"div", attributes={
"itemscope": "True",
"class": "person-scope",
"itemtype": "http://data-vocabulary.org/Person"},
text="My name is John Doe")


class ItemScopePropTestCase(ReSTExtensionTestCase):
@@ -159,10 +173,15 @@ def test_itemscope_itemprop(self):
My name is :itemprop:`John Doe <name>`
"""
self.basic_test()
self.assertHTMLContains("div", attributes={"itemscope": "", "itemtype": "http://data-vocabulary.org/Person"},
text="My name is ")
self.assertHTMLContains("span", attributes={"itemprop": "name"},
text="John Doe")
self.assertHTMLContains(
"div",
attributes={
"itemscope": "True",
"itemtype": "http://data-vocabulary.org/Person"},
text="My name is ")
self.assertHTMLContains(
"span", attributes={"itemprop": "name"},
text="John Doe")


class ItemScopeTagTestCase(ReSTExtensionTestCase):
@@ -189,18 +208,26 @@ def test_itemscope_tag(self):
My name is :itemprop:`John Doe <name>`
"""
self.basic_test()
self.assertHTMLContains("p", attributes={"itemscope": "", "itemtype": "http://data-vocabulary.org/Person"},
text="My name is ")
self.assertHTMLContains("span", attributes={"itemprop": "name"},
text="John Doe")
self.assertHTMLContains(
"p",
attributes={
"itemscope": "True",
"itemtype": "http://data-vocabulary.org/Person"},
text="My name is ")
self.assertHTMLContains(
"span", attributes={"itemprop": "name"},
text="John Doe")

def test_itemscope_tag_span(self):
# the result should be
# <span itemprop="ingredient" itemscope itemtype="http://data-vocabulary.org/RecipeIngredient">
# Thinly-sliced <span itemprop="name">apples</span>:<span itemprop="amount">6 cups</span>
# <span itemprop="ingredient" itemscope
# itemtype="http://data-vocabulary.org/RecipeIngredient">
# Thinly-sliced <span itemprop="name">apples</span>:<span
# itemprop="amount">6 cups</span>
# </span>
expected = (
'<span itemprop="ingredient" itemscope itemtype="http://data-vocabulary.org/RecipeIngredient">'
'<span itemprop="ingredient" itemscope="True" itemtype='
'"http://data-vocabulary.org/RecipeIngredient">'
'Thinly-sliced <span itemprop="name">apples</span>:'
'<span itemprop="amount">6 cups</span>'
'</span>'
@@ -212,7 +239,9 @@ def test_itemscope_tag_span(self):
Thinly-sliced :itemprop:`apples <name>`::itemprop:`6 cups <amount>`
"""
self.basic_test()
self.assertEqual(self.html.replace('\n', '').strip(), expected.replace('\n', '').strip())
self.assertEqual(
self.html.replace('\n', '').strip(),
expected.replace('\n', '').strip())


class ItemPropBlockTestCase(ReSTExtensionTestCase):
@@ -241,10 +270,16 @@ def test_itempropblock_h1(self):
Grandma's Holiday Apple Pie
"""
self.basic_test()
self.assertHTMLContains("div", attributes={"itemscope": "", "itemtype": "http://data-vocabulary.org/Recipe"},
text="")
self.assertHTMLContains("h1", attributes={"itemprop": "name"},
text="Grandma's Holiday Apple Pie")
self.assertHTMLContains(
"div",
attributes={
"itemscope": "True",
"itemtype": "http://data-vocabulary.org/Recipe"},
text="")
self.assertHTMLContains(
"h1",
attributes={"itemprop": "name"},
text="Grandma's Holiday Apple Pie")

def test_itempropblock_class(self):
# the result should be
@@ -260,42 +295,54 @@ def test_itempropblock_class(self):
Grandma's Holiday Apple Pie
"""
self.basic_test()
self.assertHTMLContains("div", attributes={"itemscope": "", "itemtype": "http://data-vocabulary.org/Recipe"},
text="")
self.assertHTMLContains("h1", attributes={"itemprop": "name",
"class": "recipe-title"},
text="Grandma's Holiday Apple Pie")
self.assertHTMLContains(
"div",
attributes={
"itemscope": "True",
"itemtype": "http://data-vocabulary.org/Recipe"},
text="")
self.assertHTMLContains(
"h1",
attributes={
"itemprop": "name",
"class": "recipe-title"},
text="Grandma's Holiday Apple Pie")

def test_itempropblock_nested(self):
# the result should be
# <div itemscope itemtype="http://data-vocabulary.org/Recipe">
# <div itemprop="instructions">
# <p itemprop="instruction">Cut and peel apples.</p>
# <p itemprop="instruction">Mix sugar and cinnamon. Use additional sugar for tart apples.</p>
# <p itemprop="instruction">Mix sugar and cinnamon. Use additional
# sugar for tart apples.</p>
# </div></div>
expected = (
'<div itemscope itemtype="http://data-vocabulary.org/Recipe">'
'<div itemscope="True" itemtype='
'"http://data-vocabulary.org/Recipe">'
'<div itemprop="instructions">'
'<p itemprop="instruction">Cut and peel apples.</p>'
'<p itemprop="instruction">Mix sugar and cinnamon. Use additional sugar for tart apples.</p>'
'<p itemprop="instruction">Mix sugar and cinnamon. '
'Use additional sugar for tart apples.</p>'
'</div></div>'
)
self.sample = """.. itemscope:: Recipe
.. itempropblock:: instructions
.. itempropblock:: instructions
.. itempropblock:: instruction
:tag: p
.. itempropblock:: instruction
:tag: p
Cut and peel apples.
Cut and peel apples.
.. itempropblock:: instruction
:tag: p
.. itempropblock:: instruction
:tag: p
Mix sugar and cinnamon. Use additional sugar for tart apples.
Mix sugar and cinnamon. Use additional sugar for tart apples.
"""
self.basic_test()
self.assertEqual(self.html.replace('\n', '').strip(), expected.replace('\n', '').strip())
self.assertEqual(
self.html.replace('\n', '').strip(),
expected.replace('\n', '').strip())


class ItemScopeNestedTestCase(ReSTExtensionTestCase):
@@ -315,15 +362,18 @@ def test_nested_scope(self):
# the result should be
# <div itemscope itemtype="http://data-vocabulary.org/Person">
# <p>My name is <span itemprop="name">John Doe</span></p>
# <p itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
# <p itemprop="address" itemscope
# itemtype="http://data-vocabulary.org/Address">
# My name is <span itemprop="name">John Doe</span>
# </p></div>
expected = (
'<div itemscope itemtype="http://data-vocabulary.org/Person">'
'<div itemscope="True" itemtype='
'"http://data-vocabulary.org/Person">'
'<p>'
'My name is <span itemprop="name">John Doe</span>'
'</p>'
'<p itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">'
'<p itemprop="address" itemscope="True" itemtype='
'"http://data-vocabulary.org/Address">'
'My name is <span itemprop="name">John Doe</span>'
'</p>'
'</div>'
@@ -339,10 +389,15 @@ def test_nested_scope(self):
My name is :itemprop:`John Doe <name>`
"""
self.basic_test()
self.assertHTMLContains("div", attributes={"itemscope": "",
"itemtype": "http://data-vocabulary.org/Person"},
text="")
self.assertEqual(self.html.replace('\n', '').strip(), expected.replace('\n', '').strip())
self.assertHTMLContains(
"div",
attributes={
"itemscope": "True",
"itemtype": "http://data-vocabulary.org/Person"},
text="")
self.assertEqual(
self.html.replace('\n', '').strip(),
expected.replace('\n', '').strip())


class ItemScopeNestedCompactTestCase(ReSTExtensionTestCase):
@@ -362,13 +417,15 @@ def test_nested_scope_compact(self):
# the result should be
# <p itemscope itemtype="http://data-vocabulary.org/Person">
# My name is <span itemprop="name">John Doe</span>
# <span itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
# <span itemprop="address" itemscope
# itemtype="http://data-vocabulary.org/Address">
# My name is <span itemprop="name">John Doe</span>
# </span></p>
expected = (
'<p itemscope itemtype="http://data-vocabulary.org/Person">'
'<p itemscope="True" itemtype="http://data-vocabulary.org/Person">'
'My name is <span itemprop="name">John Doe</span>'
'<span itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">'
'<span itemprop="address" itemscope="True" itemtype='
'"http://data-vocabulary.org/Address">'
'My name is <span itemprop="name">John Doe</span>'
'</span>'
'</p>'
@@ -386,10 +443,15 @@ def test_nested_scope_compact(self):
My name is :itemprop:`John Doe <name>`
"""
self.basic_test()
self.assertHTMLContains("p", attributes={"itemscope": "",
"itemtype": "http://data-vocabulary.org/Person"},
text="My name is ")
self.assertEqual(self.html.replace('\n', '').strip(), expected.replace('\n', '').strip())
self.assertHTMLContains(
"p",
attributes={
"itemscope": "True",
"itemtype": "http://data-vocabulary.org/Person"},
text="My name is ")
self.assertEqual(
self.html.replace('\n', '').strip(),
expected.replace('\n', '').strip())


if __name__ == "__main__":
@@ -31,16 +31,26 @@ def test_default(self):
expected = (
'<div class="publication-list">'
'<h3>2015</h3><ul>'
'<li class="publication".*>.*One article in 2015.*<a href="https://example.com/papers/a2015.html">details</a>.*<a href="/pdf/a2015.pdf">full text</a>.*</li>'
'<li class="publication".*>.*One conference in 2015.*<a href="https://example.com/papers/p2015.html">details</a>.*</li>'
'<li class="publication".*>.*One article in 2015.*'
'<a href="https://example.com/papers/a2015.html">details</a>.*'
'<a href="/pdf/a2015.pdf">full text</a>.*</li>'
'<li class="publication".*>.*One conference in 2015.*'
'<a href="https://example.com/papers/p2015.html">details</a>.*'
'</li>'
'</ul><h3>2010</h3><ul>'
'<li class="publication".*>.*One Book in 2010.*<a href="https://example.com/papers/b2010.html">details</a>.*<a href="http://example.org/b2010.pdf">full text</a>.*</li>'
'<li class="publication".*>.*One Book in 2010.*'
'<a href="https://example.com/papers/b2010.html">details</a>.*'
'<a href="http://example.org/b2010.pdf">full text</a>.*</li>'
'</ul></div>'
)
self.sample = '.. publication_list:: tests/data/publication_list/test.bib\n\t:highlight_author: Nikola Tesla'
self.sample = '.. publication_list:: tests/data/publication_list/' + \
'test.bib\n\t:highlight_author: Nikola Tesla'
self.deps = 'tests/data/publication_list/test.bib'
self.basic_test()
assert re.search(expected.replace('\n', '').strip(), self.html.replace('\n', '').strip())
assert re.search(
expected.replace('\n', '').strip(),
self.html.replace('\n', '').strip())


if __name__ == '__main__':
unittest.main()

0 comments on commit b357cc9

Please sign in to comment.