starting some unit tests before refactoring / adapting txlib to accept [<PRE blocks
authorPhil Jones <interstar@gmail.com>
Wed, 8 Aug 2018 04:09:43 +0000 (01:09 -0300)
committerPhil Jones <interstar@gmail.com>
Wed, 8 Aug 2018 04:09:43 +0000 (01:09 -0300)
python/thoughtstorms/thoughtstorms/txlib.py
python/thoughtstorms/thoughtstorms/utTxLib.py [new file with mode: 0755]

index 9bdfae1..95d2ec5 100755 (executable)
@@ -108,6 +108,12 @@ class UnknownBlock() :
        def evaluate(self,lines) :
                return ["Block of type Unknown evaluated\n"] + lines + ["\nBLOCK ENDS"]
                
+
+class PreBlock() :
+    """Does nothing, passes contents through without changing them"""
+    def evaluate(self,lines) :
+        return lines
+
 class YouTubeBlock() :
        def evaluate(self,lines) :
                data = yaml.load("\n".join(lines))
@@ -356,7 +362,7 @@ class MarkdownThoughtStorms :
                if s.strip() == "" : return s.strip()
                if s.strip()[0] != "*" : return s.strip()
                return s
-       
+
        def cook(self,p,env) :
                self.env = env
                self.table_line = DoubleCommaTabler(env)
diff --git a/python/thoughtstorms/thoughtstorms/utTxLib.py b/python/thoughtstorms/thoughtstorms/utTxLib.py
new file mode 100755 (executable)
index 0000000..4af81e8
--- /dev/null
@@ -0,0 +1,32 @@
+from txlib import MarkdownThoughtStorms, Environment
+
+import unittest 
+
+class TestMarkdownThoughtStorms(unittest.TestCase) :
+
+    def setUp(self) :
+        self.chef = MarkdownThoughtStorms()
+        self.env = Environment({},"/")
+
+
+    def test1(self) :
+        p = """
+## Hello Teenage America
+
+Goodbye *Cruel* **World**
+"""
+        self.assertEqual(self.chef.cook(p,self.env), 
+"""<h2>Hello Teenage America</h2>
+<p>Goodbye <em>Cruel</em> <strong>World</strong></p>""")
+
+    def test2(self) :
+        p = """
+[<YOUTUBE
+id : kc_Jq42Og7Q
+>]
+"""
+        self.assertEqual(self.chef.cook(p,self.env),
+"""<p><div class="youtube-embedded"><iframe width="400" height="271" src="http://www.youtube.com/embed/kc_Jq42Og7Q" frameborder="0" allowfullscreen></iframe></div></p>""")
+
+if __name__ == '__main__' :
+    unittest.main()