[CMF-checkins] CVS: CMF - test_Document.py:1.9

Jeffrey Shell jeffrey@digicool.com
Mon, 4 Jun 2001 15:06:52 -0400 (EDT)


Update of /cvs-repository/CMF/CMFDefault/tests
In directory korak.digicool.com:/home/jeffrey/InstanceHomes/about-stuff/CMF/CMFDefault/tests

Modified Files:
	test_Document.py 
Log Message:
Added new test, 'test_STX_Levels' to test structured text level
changing operatives on Document#CookedBody.  Also added some checks in 
other tests related to this change.



--- Updated File test_Document.py in package CMF --
--- test_Document.py	2001/06/01 00:25:07	1.8
+++ test_Document.py	2001/06/04 19:06:52	1.9
@@ -71,6 +71,7 @@
         assert d.description == ''
         assert d.text == ''
         assert d.text_format == 'structured-text'
+        assert d._stx_level == 1
 
     def test_BasicHtml(self):
         d = Document('foo', text=BASIC_HTML)
@@ -80,6 +81,11 @@
         assert d.Description() == 'Describe me'
         assert len(d.Contributors()) == 2
 
+        # Since the format is html, the STX level operands should
+        # have no effect.
+        ct = d.CookedBody(stx_level=3, setlevel=1)
+        assert d._stx_level == 1
+
         subj = list(d.Subject())
         assert len(subj) == 4
         subj.sort()
@@ -128,6 +134,7 @@
         assert d.Description() == 'A document by me'
         assert len(d.Contributors()) == 3
         assert string.find(d.cooked_text, '<p>') >= 0
+        assert string.find(d.CookedBody(), '<h1') >= 0
 
         # Make sure extra HTML is NOT found
         assert string.find(d.cooked_text, '<title>') == -1, d.cooked_text
@@ -143,6 +150,29 @@
             'unit tests',
             'zope'
             ]
+
+    def test_STX_Levels(self):
+        d = Document('foo', text=BASIC_STRUCTUREDTEXT)
+        assert d._stx_level == 1
+
+        ct = d.CookedBody()
+        assert string.find(d.CookedBody(), '<h1') >= 0
+        assert d._stx_level == 1
+
+        ct = d.CookedBody(stx_level=2)
+        assert not (string.find(ct, '<h1') >= 0)
+        assert string.find(ct, '<h2') >= 0
+        assert d._stx_level == 1
+
+        ct = d.CookedBody(stx_level=2, setlevel=1)
+        assert not (string.find(ct, '<h1') >= 0)
+        assert string.find(ct, '<h2') >= 0
+        assert d._stx_level == 2
+
+        ct = d.CookedBody()
+        assert d._stx_level == 2
+        assert not (string.find(d.CookedBody(), '<h1') >= 0)
+        assert string.find(d.CookedBody(), '<h2') >= 0
 
     def test_Init(self):
         d = Document('foo', text=BASIC_STRUCTUREDTEXT)