From 8697ba5b77e0e8a1df419bc9b0f323138a02ac50 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Thu, 9 Jun 2011 17:10:52 +0300
Subject: [PATCH] Add site map script testing.

---
 product/ERP5/tests/testERP5Web.py | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/product/ERP5/tests/testERP5Web.py b/product/ERP5/tests/testERP5Web.py
index fbdb3c2733..b85190548c 100644
--- a/product/ERP5/tests/testERP5Web.py
+++ b/product/ERP5/tests/testERP5Web.py
@@ -1322,6 +1322,50 @@ H茅 H茅 H茅!""", page.asText().strip())
     self.assertTrue('<cite>foo</cite>' in web_page.asEntireHTML(charset='utf-8'))
     self.assertTrue('<cite>foo</cite>' in web_page.asEntireHTML())
 
+  def test_21_WebSiteMap(self):
+    """
+      Test Web Site map script.
+    """
+    portal = self.getPortal()
+    request = self.app.REQUEST
+    website = self.setupWebSite()
+    kw = {'depth': 5, 
+          'include_subsection':1}
+          
+    website.setSiteMapSectionParent(1)
+    websection1 = website.newContent(portal_type='Web Section',
+                                     title = 'Section 1',
+                                     site_map_section_parent=1, 
+                                     visible=1)
+    websection1_1 = websection1.newContent(portal_type='Web Section',
+                                     title = 'Section 1.1',
+                                     site_map_section_parent=1, 
+                                     visible=1)                                     
+    self.stepTic()
+    site_map =  website.WebSection_getSiteMapTree(depth=5, include_subsection=1)
+    self.assertSameSet([websection1.getTitle()], 
+                       [x['translated_title'] for x in site_map])
+    self.assertSameSet([websection1_1.getTitle()], 
+                       [x['translated_title'] for x in site_map[0]['subsection']])
+    self.assertEqual(1, site_map[0]['level'])                        
+    self.assertEqual(2, site_map[0]['subsection'][0]['level'])                       
+                       
+    # check depth works
+    site_map =  website.WebSection_getSiteMapTree(depth=1, include_subsection=1)
+    self.assertEqual(None, site_map[0]['subsection'])
+    self.assertSameSet([websection1.getTitle()], 
+                       [x['translated_title'] for x in site_map])
+                       
+   
+    # hide subsections
+    websection1_1.setSiteMapSectionParent(0)
+    websection1_1.setVisible(0)    
+    self.stepTic()
+    site_map =  website.WebSection_getSiteMapTree(depth=5, include_subsection=1)    
+    self.assertSameSet([websection1.getTitle()], 
+                       [x['translated_title'] for x in site_map])
+    self.assertEqual(None, site_map[0]['subsection'])                       
+
 
 class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
   """
-- 
2.30.9