From 892092434fa748ef06ff2558c5b9dbfce9155071 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 1 Apr 2013 21:04:53 -0400 Subject: [PATCH] Skeleton for TestBuilder; adding some nodes to TreeEqualityTestCase. --- tests/_test_tree_equality.py | 38 ++++++++++++++++++++++++++++++------ tests/test_builder.py | 46 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/tests/_test_tree_equality.py b/tests/_test_tree_equality.py index 0fdb531..16f4b49 100644 --- a/tests/_test_tree_equality.py +++ b/tests/_test_tree_equality.py @@ -23,8 +23,9 @@ from __future__ import unicode_literals from unittest import TestCase -from mwparserfromhell.nodes import Template, Text, Wikilink -from mwparserfromhell.nodes.extras import Parameter +from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, + Tag, Template, Text, Wikilink) +from mwparserfromhell.nodes.extras import Attribute, Parameter from mwparserfromhell.wikicode import Wikicode class TreeEqualityTestCase(TestCase): @@ -37,8 +38,13 @@ class TreeEqualityTestCase(TestCase): def assertNodeEqual(self, expected, actual): """Assert that two Nodes have the same type and have the same data.""" registry = { - Text: self.assertTextNodeEqual, + Argument: self.assertArgumentNodeEqual, + Comment: self.assertCommentNodeEqual, + Heading: self.assertHeadingNodeEqual, + HTMLEntity: self.assertHTMLEntityNodeEqual, + Tag: self.assertTagNodeEqual, Template: self.assertTemplateNodeEqual, + Text: self.assertTextNodeEqual, Wikilink: self.assertWikilinkNodeEqual } for nodetype in registry: @@ -46,9 +52,25 @@ class TreeEqualityTestCase(TestCase): self.assertIsInstance(actual, nodetype) registry[nodetype](expected, actual) - def assertTextNodeEqual(self, expected, actual): - """Assert that two Text nodes have the same data.""" - self.assertEqual(expected.value, actual.value) + def assertArgumentNodeEqual(self, expected, actual): + """Assert that two Argument nodes have the same data.""" + pass + + def assertCommentNodeEqual(self, expected, actual): + """Assert that two Comment nodes have the same data.""" + pass + + def assertHeadingNodeEqual(self, expected, actual): + """Assert that two Heading nodes have the same data.""" + pass + + def assertHTMLEntityNodeEqual(self, expected, actual): + """Assert that two HTMLEntity nodes have the same data.""" + pass + + def assertTagNodeEqual(self, expected, actual): + """Assert that two Tag nodes have the same data.""" + pass def assertTemplateNodeEqual(self, expected, actual): """Assert that two Template nodes have the same data.""" @@ -62,6 +84,10 @@ class TreeEqualityTestCase(TestCase): self.assertWikicodeEqual(exp_param.value, act_param.value) self.assertIs(exp_param.showkey, act_param.showkey) + def assertTextNodeEqual(self, expected, actual): + """Assert that two Text nodes have the same data.""" + self.assertEqual(expected.value, actual.value) + def assertWikilinkNodeEqual(self, expected, actual): """Assert that two Wikilink nodes have the same data.""" self.assertWikicodeEqual(expected.title, actual.title) diff --git a/tests/test_builder.py b/tests/test_builder.py index a3518fd..a80d8bf 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -23,8 +23,50 @@ from __future__ import unicode_literals import unittest -class TestBuilder(unittest.TestCase): - pass +from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, + Tag, Template, Text, Wikilink) +from mwparserfromhell.nodes.extras import Attribute, Parameter +from mwparserfromhell.smart_list import SmartList +from mwparserfromhell.wikicode import Wikicode + +from ._test_tree_equality import TreeEqualityTestCase + +wrap = lambda L: Wikicode(SmartList(L)) + +class TestBuilder(TreeEqualityTestCase): + """Tests for the builder, which turns tokens into Wikicode objects.""" + + def test_text(self): + """tests for building Text nodes""" + pass + + def test_template(self): + """tests for building Template nodes""" + pass + + def test_argument(self): + """tests for building Argument nodes""" + pass + + def test_wikilink(self): + """tests for building Wikilink nodes""" + pass + + def test_html_entity(self): + """tests for building HTMLEntity nodes""" + pass + + def test_heading(self): + """tests for building Heading nodes""" + pass + + def test_comment(self): + """tests for building Comment nodes""" + pass + + def test_tag(self): + """tests for building Tag nodes""" + pass if __name__ == "__main__": unittest.main(verbosity=2)