Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/browser/configletview.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/browser/configletview.py	(revision 2523)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/browser/configletview.py	(revision 2538)
@@ -102,5 +102,4 @@
         return sitemaps
 
-
     def sitemapsDict(self):
         content, mobile, news = [],[],[]
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/config.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/config.py	(revision 2523)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/config.py	(revision 2538)
@@ -20,11 +20,4 @@
 AVAILABLE_WF_SCRIPTS = [ping_googlesitemap, '']
 
-try:
-    from Products.DCWorkflow.events import AfterTransitionEvent
-except ImportError:
-    IS_PLONE_3 = False
-else:
-    IS_PLONE_3 = True
-
 # Turn-ON/OFF portal_catalog
 # updating on product installation
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/sitemap.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/sitemap.py	(revision 2523)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/sitemap.py	(revision 2538)
@@ -158,41 +158,4 @@
         """
         self.getField('pingTransitions').set(self, value)
-        if not IS_PLONE_3:
-            # Update Workflow if needed
-            pw = getToolByName(self, 'portal_workflow')
-            #ping_googlesitemap = PING_EMETHODS_MAP[self.getSitemapType()]
-            transmap = {}
-            for key in value:
-                if key.find('#')>0:
-                    ids = key.split('#')
-                    wfid = ids[0]
-                    if not wfid in transmap.keys():
-                        transmap[wfid]=[]
-                    transmap[wfid].append(ids[1])
-            for wfid in transmap.keys():
-                workflow = pw.getWorkflowById(wfid)
-                if ping_googlesitemap not in workflow.scripts.objectIds():
-                    workflow.scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod(
-                        ping_googlesitemap,
-                        'Ping sitemap',
-                        'quintagroup.plonegooglesitemaps.ping_googlesitemap',
-                        ping_googlesitemap)
-                transitions_set = transmap[wfid]
-                for transition in workflow.transitions.values():
-                    trid = transition.id
-                    tras = transition.after_script_name
-                    if (tras == '') and (trid in transitions_set):
-                        #set
-                        after_script = ping_googlesitemap
-                    elif (tras == ping_googlesitemap) and not (trid in transitions_set):
-                        #reset
-                        after_script = ''
-                    else:
-                        #avoid properties set
-                        continue
-                    transition.setProperties(title=transition.title,
-                        new_state_id=transition.new_state_id,
-                        after_script_name=after_script,
-                        actbox_name=transition.actbox_name)
 
 atapi.registerType(Sitemap, PROJECTNAME)
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/interfaces.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/interfaces.py	(revision 2523)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/interfaces.py	(revision 2538)
@@ -4,4 +4,6 @@
 from zope.app.container.constraints import contains
 from zope.app.container.constraints import containers
+
+from Products.DCWorkflow.interfaces import IAfterTransitionEvent
 
 from quintagroup.plonegooglesitemaps import qPloneGoogleSitemapsMessageFactory as _
@@ -11,26 +13,2 @@
 class ISitemap(Interface):
     """Search engine Sitemap content type"""
-
-try:
-    from Products.DCWorkflow.interfaces import IAfterTransitionEvent
-except ImportError:
-    # Copy IAfterTransitionEvent from Plone-3/Products.DCWorkflow.interfaces
-    from zope.interface import Interface, Attribute
-    from zope.app.event.interfaces import IObjectEvent
-
-    class ITransitionEvent(IObjectEvent):
-        """An event that's fired upon a workflow transition.
-        """
-
-        workflow = Attribute(u"The workflow definition triggering the transition")
-        old_state = Attribute(u"The state definition of the workflow state before the transition")
-        new_state = Attribute(u"The state definition of the workflow state before after transition")
-        transition = Attribute(u"The transition definition taking place. "
-                                "May be None if this is the 'transition' to the initial state.")
-        status = Attribute(u"The status dict of the object.")
-        kwargs = Attribute(u"Any keyword arguments passed to doActionFor() when the transition was invoked")
-
-    class IAfterTransitionEvent(ITransitionEvent):
-
-        """An event that's fired after a workflow transition.
-        """
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py	(revision 2523)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py	(revision 2538)
@@ -9,4 +9,5 @@
 
 from zope.testing import doctestunit
+from zope.interface import Interface
 from zope.component import testing
 from Testing import ZopeTestCase as ztc
@@ -25,4 +26,5 @@
 from quintagroup.plonegooglesitemaps.config import PROJECTNAME
 from quintagroup.plonegooglesitemaps.config import ping_googlesitemap
+from quintagroup.plonegooglesitemaps.browser import mobilesitemapview
 
 quintagroup.plonegooglesitemaps.config.testing = 1
@@ -30,5 +32,9 @@
 
 
-class MixinTestCase:
+class IMobileMarker(Interface):
+    """Test Marker interface for mobile objects"""
+
+
+class MixinTestCase(object):
     """ Define layer and common afterSetup method with package installation.
         Package installation on plone site setup impossible because of
@@ -39,4 +45,15 @@
     def afterSetUp(self):
         self.loginAsPortalOwner()
+        self.workflow = self.portal.portal_workflow
+        self.orig_mobile_ifaces = None
+
+    def patchMobile(self):
+        # patch mobile sitemap view
+        self.orig_mobile_ifaces = mobilesitemapview.MOBILE_INTERFACES
+        mobilesitemapview.MOBILE_INTERFACES = [IMobileMarker.__identifier__,]
+
+    def beforeTearDown(self):
+        if self.orig_mobile_ifaces is not None:
+            mobilesitemapview.MOBILE_INTERFACES = self.orig_mobile_ifaces
 
 
@@ -44,6 +61,11 @@
     """ For unit tests """
 
+
 class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase):
     """ For functional tests """
+
+    def afterSetUp(self):
+        super(FunctionalTestCase, self).afterSetUp()
+        self.auth = "%s:%s" % (portal_owner, default_password)
 
 # Initialize all needed zcml directives
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testConfiglet.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testConfiglet.py	(revision 2538)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testConfiglet.py	(revision 2538)
@@ -0,0 +1,94 @@
+#
+# Tests for quintagroup.plonegooglesitemaps
+#
+
+from base import *
+from cgi import FieldStorage
+from tempfile import TemporaryFile, NamedTemporaryFile
+
+from OFS.Image import cookId
+from Products.CMFPlone.utils import _createObjectByType
+from ZPublisher.HTTPRequest import FileUpload
+
+
+class TestConfigletSettings(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestConfigletSettings, self).afterSetUp()
+        self.settingsURL = '/'+self.portal.absolute_url(1) + '/prefs_gsm_settings'
+
+    def submitForm(self, fdata, fextra={}):
+        form = {'form.submitted': 1}
+        form.update(fdata)
+        return self.publish(self.settingsURL, request_method='POST',
+                            stdin=StringIO(urlencode(form)),
+                            basic=self.auth, extra=fextra)
+
+    def testInitButtons(self):
+        settings = self.publish(self.settingsURL, self.auth).getBody()
+        self.assert_("Add Content Sitemap" in settings)
+        self.assert_("Add News Sitemap" in settings)
+        self.assert_("Add Mobile Sitemap" in settings)
+
+    def testAddContentSitemap(self):
+        resp = self.submitForm({'form.button.AddContent': "Add Content Sitemap"})
+        self.assertEqual(resp.getStatus() / 100, 3)
+        self.assertEqual(resp.getHeader("Location").endswith("sitemap.xml/edit"), True)
+        # Add SM
+        sm = self.portal["sitemap.xml"]
+        #sm.setPortalTypes(("Documents",))
+        newform = self.publish(self.settingsURL, basic=self.auth).getBody()
+        self.assertEqual('href="http://nohost/plone/sitemap.xml/edit"' in newform, True)
+        self.assertEqual("form.button.AddContent" in newform, False)
+
+    def testAddNewsSitemap(self):
+        resp = self.submitForm({'form.button.AddNews': "Add News Sitemap"})
+        self.assertEqual(resp.getStatus() / 100, 3)
+        self.assertEqual(resp.getHeader("Location").endswith("news-sitemap.xml/edit"), True)
+        # Add SM
+        sm = self.portal["news-sitemap.xml"]
+        #sm.setPortalTypes(("News Item",))
+        newform = self.publish(self.settingsURL, basic=self.auth).getBody()
+        self.assertEqual('href="http://nohost/plone/news-sitemap.xml/edit"' in newform, True)
+        self.assertEqual("form.button.AddNews" in newform, False)
+
+    def testAddMobileSitemap(self):
+        resp = self.submitForm({'form.button.AddMobile': "Add Mobile Sitemap"})
+        self.assertEqual(resp.getStatus() / 100, 3)
+        self.assertEqual(resp.getHeader("Location").endswith("mobile-sitemap.xml/edit"), True)
+        # Add SM
+        sm = self.portal["mobile-sitemap.xml"]
+        #sm.setPortalTypes(("Documents",))
+        newform = self.publish(self.settingsURL, basic=self.auth).getBody()
+        self.assertEqual('href="http://nohost/plone/mobile-sitemap.xml/edit"' in newform, True)
+        self.assertEqual("form.button.AddMobile" in newform, False)
+
+
+class TestConfigletOverview(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestConfigletOverview, self).afterSetUp()
+        self.overviewURL = '/'+self.portal.absolute_url(1) + '/prefs_gsm_overview'
+        self.smURL = "%s/sitemap.xml" % self.portal.absolute_url()
+        
+    def testInitial(self):
+        overview = self.publish(self.overviewURL, self.auth).getBody()
+        self.assert_(not self.smURL in overview)
+
+    def testPresentedSM(self):
+        _createObjectByType("Sitemap", self.portal, id="sitemap.xml",
+                            sitemapType="content")
+        overview = self.publish(self.overviewURL, self.auth).getBody()
+        self.assert_(self.smURL in overview)
+
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestConfigletSettings))
+    suite.addTest(makeSuite(TestConfigletOverview))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+#    framework()
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testGoogleSitemaps.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testGoogleSitemaps.py	(revision 2538)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testGoogleSitemaps.py	(revision 2538)
@@ -0,0 +1,145 @@
+#
+# Tests for quintagroup.plonegooglesitemaps
+#
+
+from base import *
+from cgi import FieldStorage
+from tempfile import TemporaryFile, NamedTemporaryFile
+
+from OFS.Image import cookId
+from Products.CMFPlone.utils import _createObjectByType
+from ZPublisher.HTTPRequest import FileUpload
+
+
+def prepareUploadFile(prefix=""):
+    """ Helper function for prerare file to uploading """
+    fp = NamedTemporaryFile(mode='w+', prefix=prefix)
+    fp.write("google-site-verification: " + fp.name)
+    fp.seek(0,2)
+    fsize = fp.tell()
+    fp.seek(0)
+
+    env = {'REQUEST_METHOD':'PUT'}
+    headers = {'content-type':'text/plain',
+               'content-length': fsize,
+               'content-disposition':'attachment; filename=%s' % fp.name}
+    fs = FieldStorage(fp=fp, environ=env, headers=headers)
+    return FileUpload(fs), fp
+
+
+class TestGoogleSitemaps(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestGoogleSitemaps, self).afterSetUp()
+
+        _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
+        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps'
+        self.gsm_props = self.portal.portal_properties['googlesitemap_properties']
+
+        # Add testing document to portal
+        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc')
+        self.my_doc.edit(text_format='plain', text='hello world')
+
+    def testSitemap(self):
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        parsed_sitemap = parse(sitemap)
+        start = parsed_sitemap['start']
+        data = parsed_sitemap['data']
+        self.assert_('urlset' in start.keys())
+        self.assertFalse(self.my_doc.absolute_url(0) in data,
+                         'Wrong content present in the sitemap')
+
+        self.workflow.doActionFor(self.my_doc, 'publish')
+
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        parsed_sitemap = parse(sitemap)
+        start = parsed_sitemap['start']
+        data = parsed_sitemap['data']
+        self.assertEqual(len(start.keys()), 4)
+        self.assert_('urlset' in start.keys())
+        self.assert_('url' in start.keys())
+        self.assert_('loc' in start.keys())
+        self.assert_('lastmod' in start.keys())
+
+        self.assertTrue(self.my_doc.absolute_url(0) in data, 'Incorect url')
+
+    def testVerificationFileCreation(self):
+        fp, fname = None, None
+        try:
+            fupload, fp = prepareUploadFile()
+            fname, ftitle = cookId('', '', fupload)
+            self.portal.REQUEST.form['verification_file'] = fupload
+            self.portal.gsm_create_verify_file()
+        finally:
+            if fp: fp.close()
+        vf_created = hasattr(self.portal, fname)
+        self.assert_(vf_created, 'Verification file not created')
+
+    def testVerificationForm(self):
+        verifyConfigUrl = '/'+self.portal.absolute_url(1) + '/prefs_gsm_verification'
+        verif_config = self.publish(verifyConfigUrl, self.auth).getBody()
+        rexp_input_acitve = re.compile('<input\s+name="verification_file"\s+([^>]*)>', re.I|re.S)
+        rexp_button_acitve = re.compile('<input\s+name="form.button.CreateFile"\s+([^>]*)>', re.I|re.S)
+        rexp_delete_button = re.compile('<input\s+name="form.button.DeleteFile"\s+[^>]*>', re.I|re.S)
+
+        input_acitve = rexp_input_acitve.search(verif_config)
+        button_acitve = rexp_button_acitve.search(verif_config)
+        delete_button = rexp_delete_button.match(verif_config)
+
+        self.assert_(input_acitve and not 'disabled' in input_acitve.groups(1))
+        self.assert_(button_acitve and not 'disabled' in button_acitve.groups(1))
+        self.assert_(not delete_button)
+
+        fp, fname = None, None
+        try:
+            fupload, fp = prepareUploadFile()
+            fname, ftitle = cookId('', '', fupload)
+            self.portal.REQUEST.form['verification_file'] = fupload
+            self.portal.gsm_create_verify_file()
+        finally:
+            if fp: fp.close()
+
+        input_acitve = rexp_input_acitve.search(verif_config)
+        button_acitve = rexp_button_acitve.search(verif_config)
+        delete_button = rexp_delete_button.match(verif_config)
+
+        verif_config = self.publish(verifyConfigUrl, self.auth).getBody()
+        self.assert_(input_acitve and not 'disabled' in input_acitve.groups(1))
+        self.assert_(not delete_button)
+
+    def testMultiplyVerificationFiles(self):
+        verifyConfigUrl = '/'+self.portal.absolute_url(1) + '/prefs_gsm_verification'
+        fnames = []
+        for i in [1,2]:
+            fp, fname, response = None, None, None
+            try:
+                fupload, fp = prepareUploadFile(prefix=str(i))
+                fname, ftitle = cookId('', '', fupload)
+                form = {'form.button.CreateFile': 'Create verification file',
+                        'form.submitted': 1}
+                extra_update = {'verification_file': fupload}
+                response = self.publish(verifyConfigUrl, request_method='POST',
+                                        stdin=StringIO(urlencode(form)),
+                                        basic=self.auth, extra=extra_update)
+            finally:
+                if fp: fp.close()
+            
+            self.assertEqual(response.getStatus(), 200)
+            self.assert_(fname in self.gsm_props.getProperty('verification_filenames',[]),
+                             self.gsm_props.getProperty('verification_filenames',[]))
+            fnames.append(fname)
+
+        self.assertEqual(len([1 for vf in fnames \
+            if vf in self.gsm_props.getProperty('verification_filenames',[])]), 2,
+            self.gsm_props.getProperty('verification_filenames',[]))
+
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestGoogleSitemaps))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+#    framework()
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testInstallation.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testInstallation.py	(revision 2538)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testInstallation.py	(revision 2538)
@@ -0,0 +1,81 @@
+from base import *
+from zope.component import getSiteManager
+from archetypes.schemaextender.interfaces import ISchemaExtender
+
+
+class TestGoogleSitemapsInstallation(TestCase):
+
+    def testType(self):
+        pt = self.portal.portal_types
+        self.assert_('Sitemap' in pt.objectIds(), 
+            'No "Sitemap" type after installation')
+        #Test views
+        views = pt.getTypeInfo('Sitemap').view_methods
+        self.assert_('sitemap.xml' in views, 
+            'No "sitemap.xml" view for Sitemap type')
+        self.assert_('mobile-sitemap.xml' in views, 
+            'No "mobile-sitemap.xml" view for Sitemap type')
+        self.assert_('news-sitemap.xml' in views, 
+            'No "news-sitemap.xml" view for Sitemap type')
+
+    def testGSMProperties(self):
+        pp = self.portal.portal_properties
+
+        # Test types_not_searched
+        self.assert_("Sitemap" in pp['site_properties'].getProperty('types_not_searched'), 
+            'No "Sitemap" added to types not searched on installation')
+        # Test metaTypesNotToList
+        self.assert_("Sitemap" in pp['navtree_properties'].getProperty('metaTypesNotToList'), 
+            'No "Sitemap" added to types not to list on installation')
+
+        # Test 'googlesitemap_properties'
+        self.assert_('googlesitemap_properties' in pp.objectIds(), 
+            'No "googlesitemap_properties" after installation')
+        qsmprops = pp['googlesitemap_properties']
+        self.assert_(qsmprops.hasProperty('verification_filenames'),
+            'No "verification_filenames" property added on installation')
+
+    def testSkins(self):
+        ps = self.portal.portal_skins
+        self.assert_('plonegooglesitemaps' in ps.objectIds(), 
+            'No "plonegooglesitemaps" skin layer in portal_skins')
+        self.assert_('plonegooglesitemaps' in ps.getSkinPath(ps.getDefaultSkin()),
+            'No "plonegooglesitemaps" skin layer in default skin')
+
+    def testConfiglet(self):
+        cp = self.portal.portal_controlpanel
+        self.assert_([1 for ai in cp.listActionInfos() if ai['id']=='GoogleSitemaps'], 
+            'No "GoogleSitemaps" configlet added to plone control panel')
+
+    def testNewsSchemaExtenderRegistered(self):
+        lsm = getSiteManager(self.portal)
+        news = self.portal.invokeFactory("News Item", id="test_news")
+        news = getattr(self.portal, "test_news")
+        self.assertNotEqual(lsm.queryAdapter(news, interface=ISchemaExtender), None)
+
+
+class TestGoogleSitemapsUninstallation(TestCase):
+
+    def afterSetUp(self):
+        super(TestGoogleSitemapsUninstallation, self).afterSetUp()
+        self.portal.portal_quickinstaller.uninstallProducts(
+            products=['quintagroup.plonegooglesitemaps',])
+        self._refreshSkinData()
+
+    def testNewsSchemaExtenderUnregistered(self):
+        lsm = getSiteManager(self.portal)
+        news = self.portal.invokeFactory("News Item", id="test_news")
+        news = getattr(self.portal, "test_news")
+        self.assertEqual(lsm.queryAdapter(news, interface=ISchemaExtender), None)
+
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestGoogleSitemapsInstallation))
+    suite.addTest(makeSuite(TestGoogleSitemapsUninstallation))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+#    framework()
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testMobileSitemaps.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testMobileSitemaps.py	(revision 2538)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testMobileSitemaps.py	(revision 2538)
@@ -0,0 +1,95 @@
+from base import *
+from DateTime import DateTime
+
+from zope.interface import alsoProvides
+from zope.component import queryMultiAdapter
+from zope.component import getSiteManager, getGlobalSiteManager
+from archetypes.schemaextender.interfaces import ISchemaExtender
+
+from Products.CMFPlone.utils import _createObjectByType
+
+from quintagroup.plonegooglesitemaps.browser import mobilesitemapview
+from quintagroup.plonegooglesitemaps.browser.commonview import CommonSitemapView
+from quintagroup.plonegooglesitemaps.browser.mobilesitemapview import MobileSitemapView
+
+class TestMobileSitemapsXML(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestMobileSitemapsXML, self).afterSetUp()
+        self.patchMobile()
+        _createObjectByType("Sitemap", self.portal, id="mobile-sitemap.xml",
+                            sitemapType="mobile", portalTypes=("Document",))
+        self.portal["mobile-sitemap.xml"].at_post_create_script()
+        # Add testing mobile item to portal
+        self.pubdate = (DateTime()+1).strftime("%Y-%m-%d")
+        self.my_mobile = _createObjectByType('Document', self.portal, id='my_mobile')
+        alsoProvides(self.my_mobile, IMobileMarker)
+        self.my_mobile.edit(text="Test mobile item", title="First mobile (test)",
+                            effectiveDate=self.pubdate)
+        self.workflow.doActionFor(self.my_mobile, "publish")
+        self.reParse()
+
+    def reParse(self):
+        # Parse mobile sitemap
+        self.sitemap = self.publish("/"+self.portal.absolute_url(1) + "/mobile-sitemap.xml",
+                                    "%s:%s" % (portal_owner, default_password)).getBody()
+        parsed_sitemap = parse(self.sitemap)
+        self.start = parsed_sitemap["start"]
+        self.data = parsed_sitemap["data"]
+
+    def test_urlset(self):
+        self.assert_("urlset" in self.start.keys())
+        urlset = self.start["urlset"]
+        self.assertEqual(urlset.get("xmlns", ""), "http://www.sitemaps.org/schemas/sitemap/0.9")
+        self.assertEqual(urlset.get("xmlns:mobile", ""), "http://www.google.com/schemas/sitemap-mobile/1.0")
+
+    def test_url(self):
+        self.assert_("url" in self.start.keys())
+
+    def test_loc(self):
+        self.assert_("loc" in self.start.keys())
+        self.assert_(self.portal.absolute_url() + "/my_mobile" in self.data)
+
+    def test_lastmod(self):
+        md = [f for k,f in mobilesitemapview.MobileSitemapView.additional_maps \
+              if k=='modification_date'][0]
+        bmobile = self.portal.portal_catalog(id="my_mobile")[0]
+        self.assert_("lastmod" in self.start.keys())
+        self.assert_(md(bmobile) in self.data, "Wrong 'modified date':" \
+                     " must be '%s', but exist: '%s'" % (md(bmobile), self.data))
+
+class TestMobileSitemaps(TestCase):
+
+    def afterSetUp(self):
+        super(TestMobileSitemaps, self).afterSetUp()
+        # create mobile sitemap
+        _createObjectByType("Sitemap", self.portal, id="mobile-sitemap.xml",
+                            sitemapType="mobile", portalTypes=("Document",))
+        mobile_sm = self.portal["mobile-sitemap.xml"]
+        mobile_sm.at_post_create_script()
+        self.default_layout = mobile_sm.getProperty('layout', "")
+        self.mobile_view = queryMultiAdapter((mobile_sm, self.portal.REQUEST),
+                               name=self.default_layout)
+
+    def testLayout(self):
+        self.assert_(self.default_layout == "mobile-sitemap.xml")
+
+    def testInterface(self):
+        self.assert_(mobilesitemapview.ISitemapView.providedBy(self.mobile_view))
+
+    def testClasses(self):
+        self.assert_(isinstance(self.mobile_view, MobileSitemapView))
+        self.assert_(isinstance(self.mobile_view, CommonSitemapView))
+
+    def testAdditionalMaps(self):
+        self.assert_(hasattr(self.mobile_view, "additional_maps"))
+        self.assert_([1 for k,f in self.mobile_view.additional_maps \
+                 if k=="modification_date"])
+    
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestMobileSitemapsXML))
+    suite.addTest(makeSuite(TestMobileSitemaps))
+    return suite
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py	(revision 2523)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py	(revision 2538)
@@ -17,10 +17,9 @@
         # Add testing news item to portal
         self.pubdate = (DateTime()+1).strftime("%Y-%m-%d")
-        my_news = self.portal.invokeFactory("News Item", id="my_news")
-        self.my_news = self.portal["my_news"]
+        self.my_news = _createObjectByType('News Item', self.portal, id='my_news')
         self.my_news.edit(text="Test news item", title="First news (test)", language="ua",
                           effectiveDate=self.pubdate, gsm_access="Registration",
                           gsm_genres=("PressRelease",), gsm_stock="NASDAQ:AMAT, BOM:500325")
-        self.portal.portal_workflow.doActionFor(self.my_news, "publish")
+        self.workflow.doActionFor(self.my_news, "publish")
         self.reParse()
 
@@ -91,8 +90,9 @@
     def test_ngenresForNotExtended(self):
         # No genres should present for not extended content type
-        self.portal.invokeFactory("Document", id="my_doc")
-        my_doc = getattr(self.portal, "my_doc")
+        my_doc = _createObjectByType('Document', self.portal, id='my_doc')
+        #self.portal.invokeFactory("Document", id="my_doc")
+        #my_doc = getattr(self.portal, "my_doc")
         my_doc.edit(text="Test document")
-        self.portal.portal_workflow.doActionFor(my_doc, "publish")
+        self.workflow.doActionFor(my_doc, "publish")
         self.portal["news-sitemaps"].edit(portalTypes=("Document",))
         self.reParse()
@@ -116,8 +116,7 @@
         # Add minimal testing news item to portal
         self.pubdate = (DateTime()+1).strftime("%Y-%m-%d")
-        my_news = self.portal.invokeFactory("News Item", id="my_news")
-        self.my_news = self.portal["my_news"]
+        self.my_news = _createObjectByType('News Item', self.portal, id='my_news')
         self.my_news.edit(effectiveDate=self.pubdate)
-        self.portal.portal_workflow.doActionFor(self.my_news, "publish")
+        self.workflow.doActionFor(self.my_news, "publish")
         self.reParse()
 
@@ -168,10 +167,6 @@
     def afterSetUp(self):
         super(TestSchemaExtending, self).afterSetUp()
-        self.loginAsPortalOwner()
-        # Add testing news item to portal
-        my_news = self.portal.invokeFactory("News Item", id="my_news")
-        self.my_news = self.portal["my_news"]
-        my_doc = self.portal.invokeFactory("Document", id="my_doc")
-        self.my_doc = self.portal["my_doc"]
+        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc')
+        self.my_news = _createObjectByType('News Item', self.portal, id='my_news')
 
     def testExtendNewsItemByDefault(self):
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testPinging.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testPinging.py	(revision 2538)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testPinging.py	(revision 2538)
@@ -0,0 +1,84 @@
+from base import *
+from Products.CMFPlone.utils import _createObjectByType
+
+
+class TestPinging(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestPinging, self).afterSetUp()
+        self.workflow.setChainForPortalTypes(pt_names=('News Item','Document'),
+                                             chain="simple_publication_workflow")
+        self.gsm_props = self.portal.portal_properties['googlesitemap_properties']
+        # Add sitemaps
+        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
+        self.contentSM.setPingTransitions(('simple_publication_workflow#publish',))
+        self.newsSM = _createObjectByType('Sitemap', self.portal, id='news-sitemaps')
+        self.newsSM.setPortalTypes(('News Item','Document'))
+        self.newsSM.setPingTransitions(('simple_publication_workflow#publish',))
+        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps'
+        # Add testing document to portal
+        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc')
+        self.my_news = _createObjectByType('News Item', self.portal, id='my_news')
+
+    def testAutomatePinging(self):
+        # 1. Check for pinging both sitemaps
+        back_out, myout = sys.stdout, StringIO()
+        sys.stdout = myout
+        try:
+            self.workflow.doActionFor(self.my_doc, 'publish')
+            myout.seek(0)
+            data = myout.read()
+        finally:
+            sys.stdout = back_out
+
+        self.assert_('Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.contentSM.id, data))
+        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
+
+        # 2. Check for pinging only news-sitemap sitemaps
+        back_out, myout = sys.stdout, StringIO()
+        sys.stdout = myout
+        try:
+            self.workflow.doActionFor(self.my_news, 'publish')
+            myout.seek(0)
+            data = myout.read()
+        finally:
+            sys.stdout = back_out
+
+        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
+        self.assert_(not 'Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
+                     "Pinged %s on news: '%s'" % (self.contentSM.id, data))
+
+    def testPingingWithSetupForm(self):
+        # Ping news and content sitemaps
+        formUrl = '/'+self.portal.absolute_url(1) + '/prefs_gsm_settings'
+        qs = 'smselected:list=%s&smselected:list=%s&form.button.Ping=1&form.submitted=1' % \
+             (self.contentSM.id, self.newsSM.id)
+
+        back_out, myout = sys.stdout, StringIO()
+        sys.stdout = myout
+        try:
+            response = self.publish("%s?%s" % (formUrl, qs), basic=self.auth)
+            myout.seek(0)
+            data = myout.read()
+        finally:
+            sys.stdout = back_out
+
+        self.assert_('Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.contentSM.id, data))
+        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
+
+
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestPinging))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+#    framework()
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSecurity.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSecurity.py	(revision 2538)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSecurity.py	(revision 2538)
@@ -0,0 +1,128 @@
+#
+# Tests related to general Sitemap type.
+#
+from base import *
+from zope.interface import alsoProvides
+from Products.Archetypes import atapi
+from Products.CMFPlone.utils import _createObjectByType
+
+class MixinSecurity(FunctionalTestCase):
+
+    def getview(self, vpath):
+        return self.publish("/"+self.portal.absolute_url(1)+"/"+vpath, self.auth)
+
+
+class TestSecurityConfigletManager(MixinSecurity):
+
+    def afterSetUp(self):
+        super(TestSecurityConfigletManager, self).afterSetUp()
+        self.auth = "admin:admin"
+        self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), [])
+
+    def testConfigOverview(self):
+        resp = self.getview("prefs_gsm_overview")
+        self.assertEqual(resp.status / 100, 2)
+
+    def testConfigSettings(self):
+        resp = self.getview("prefs_gsm_settings")
+        self.assertEqual(resp.status / 100, 2)
+
+    def testConfigVerification(self):
+        resp = self.getview("prefs_gsm_verification")
+        self.assertEqual(resp.status / 100, 2)
+
+
+class TestSecurityConfigletNotManager(MixinSecurity):
+
+    def afterSetUp(self):
+        super(TestSecurityConfigletNotManager, self).afterSetUp()
+        self.auth = "mem:mem"
+        self.portal.portal_membership.addMember('mem', 'mem', ('Member',), [])
+
+    def testConfigOverview(self):
+        resp = self.getview("prefs_gsm_overview")
+        self.assertNotEqual(resp.status / 100, 2)
+
+    def testConfigSettings(self):
+        resp = self.getview("prefs_gsm_settings")
+        self.assertNotEqual(resp.status / 100, 2)
+
+    def testConfigVerification(self):
+        resp = self.getview("prefs_gsm_verification")
+        self.assertNotEqual(resp.status / 100, 2)
+
+
+SM_TYPES = {
+  "content": {"id": "sitemap.xml", "types": ("Document",)},
+  "news": {"id": "news-sitemap.xml", "types": ("News Item",)},
+  "mobile": {"id": "mobile-sitemap.xml", "types": ("Document",)},
+}
+from DateTime import DateTime
+
+class TestSecuritySiteMaps(MixinSecurity):
+
+    def afterSetUp(self):
+        super(TestSecuritySiteMaps, self).afterSetUp()
+        self.auth = ":"
+        self.patchMobile()
+        self.createSMaps()
+        self.createContent()
+
+    def createSMaps(self):
+        self.smaps = {}
+        for smtype, smdata in SM_TYPES.items():
+            _createObjectByType("Sitemap", self.portal, id=smdata["id"],
+                                sitemapType=smtype, portalTypes=smdata["types"])
+            sm = getattr(self.portal, smdata["id"])
+            sm.at_post_create_script()
+            self.smaps[smtype] = sm
+
+    def createContent(self):
+        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc')
+        self.workflow.doActionFor(self.my_doc, 'publish')
+        self.my_news = _createObjectByType('News Item', self.portal, id='my_news')
+        self.my_news.edit(title="My News Item (test)",
+                          effectiveDate=DateTime().strftime("%Y-%m-%d"))
+        self.workflow.doActionFor(self.my_news, 'publish')
+        # mobile content must provides additional interfaces to fall into mobile sitemap
+        alsoProvides(self.my_doc, IMobileMarker)
+        self.my_doc.reindexObject()
+        self.my_news.reindexObject()
+
+    def reparse(self, data):
+        parsed = parse(data)
+        return parsed["start"], parsed["data"]
+
+    def testContentSM(self):
+        resp = self.getview("sitemap.xml")
+        self.assertEqual(resp.status / 100, 2)
+        start, data = self.reparse(resp.getBody())
+        self.assert_("loc" in start)
+        self.assert_(self.my_doc.absolute_url() in data)
+        
+    def testNewsSM(self):
+        resp = self.getview("news-sitemap.xml")
+        self.assertEqual(resp.status / 100, 2)
+        start, data = self.reparse(resp.getBody())
+        self.assert_("n:name" in start)
+        self.assert_("My News Item" in data)
+        
+    def testMobileSM(self):
+        resp = self.getview("mobile-sitemap.xml")
+        self.assertEqual(resp.status / 100, 2)
+        start, data = self.reparse(resp.getBody())
+        self.assert_("loc" in start)
+        self.assert_(self.my_doc.absolute_url() in data)
+        
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestSecurityConfigletManager))
+    suite.addTest(makeSuite(TestSecurityConfigletNotManager))
+    suite.addTest(makeSuite(TestSecuritySiteMaps))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+#    framework()
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSitemaps.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSitemaps.py	(revision 2538)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testSitemaps.py	(revision 2538)
@@ -0,0 +1,226 @@
+#
+# Tests related to general Sitemap type.
+#
+from base import *
+from Products.Archetypes import atapi
+from Products.CMFPlone.utils import _createObjectByType
+
+
+class TestSitemapType(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestSitemapType, self).afterSetUp()
+        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
+
+    def testFields(self):
+        field_ids = map(lambda x:x.getName(), self.contentSM.Schema().fields())
+        # test old Sitemap settings fields
+        self.assert_('id' in field_ids)
+        self.assert_('portalTypes' in field_ids)
+        self.assert_('states' in field_ids)
+        self.assert_('blackout_list' in field_ids)
+        self.assert_('urls' in field_ids)
+        self.assert_('pingTransitions' in field_ids)
+        # test new sitemap type field
+        self.assert_('sitemapType' in field_ids)
+
+    def testSitemapTypes(self):
+        sitemap_types = self.contentSM.getField('sitemapType').Vocabulary().keys()
+        self.assert_('content' in sitemap_types)
+        self.assert_('mobile' in sitemap_types)
+        self.assert_('news' in sitemap_types)
+
+    def testAutoSetLayout(self):
+        response = self.publish('/%s/createObject?type_name=Sitemap' % \
+                                self.portal.absolute_url(1), basic=self.auth)
+        location = response.getHeader('location')
+        newurl = location[location.find('/'+self.portal.absolute_url(1)):]
+
+        msm_id = 'mobile_sitemap'
+        form = {'id': msm_id,
+                'sitemapType':'mobile',
+                'portalTypes':['Document',],
+                'states':['published'],
+                'form_submit':'Save',
+                'form.submitted':1,
+                }
+        post_data = StringIO(urlencode(form))
+        response = self.publish(newurl, request_method='POST', stdin=post_data, basic=self.auth)
+        msitemap = getattr(self.portal, msm_id)
+
+        self.assertEqual(msitemap.defaultView(), 'mobile-sitemap.xml')
+
+    def txestPingSetting(self):
+        pwf = self.workflow['plone_workflow']
+        self.assertEqual(self.contentSM.getPingTransitions(), ())
+
+        self.contentSM.setPingTransitions(('plone_workflow#publish',))
+        self.assertEqual(self.contentSM.getPingTransitions(), ('plone_workflow#publish',))
+        self.assert_(ping_googlesitemap in pwf.scripts.keys(),"Not add wf script")
+
+    def testWorkflowStates(self):
+        wfstates = self.contentSM.getWorkflowStates()
+        self.assertEqual(isinstance(wfstates, atapi.DisplayList), True)
+        self.assertEqual("published" in wfstates.keys(), True)
+
+    def testWorkflowStates(self):
+        wftrans = self.contentSM.getWorkflowTransitions()
+        self.assertEqual(isinstance(wftrans, atapi.DisplayList), True)
+        self.assertEqual("simple_publication_workflow#publish" in wftrans.keys(), True)
+
+
+class TestSettings(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestSettings, self).afterSetUp()
+        self.gsm_props = self.portal.portal_properties['googlesitemap_properties']
+        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
+        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps'
+        # Add testing document to portal
+        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc')
+        self.my_doc.edit(text_format='plain', text='hello world')
+        self.my_doc_url = self.my_doc.absolute_url()
+
+    def testMetaTypeToDig(self):
+        self.workflow.doActionFor(self.my_doc, 'publish')
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(hasURL(sitemap, self.my_doc_url))
+
+        self.contentSM.setPortalTypes([])
+
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(not hasURL(sitemap, self.my_doc_url))
+
+        self.contentSM.setPortalTypes(['Document'])
+
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(hasURL(sitemap, self.my_doc_url))
+
+    def testStates(self):
+        self.workflow.doActionFor(self.my_doc, 'publish')
+        self.contentSM.setStates(['visible'])
+
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(not hasURL(sitemap, self.my_doc_url))
+
+        self.contentSM.setStates(['published'])
+
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(hasURL(sitemap, self.my_doc_url))
+
+    def test_blackout_entries(self):
+        self.workflow.doActionFor(self.my_doc, 'publish')
+        self.contentSM.setBlackout_list((self.my_doc.getId(),))
+
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(not hasURL(sitemap, self.my_doc_url))
+
+        self.contentSM.setBlackout_list([])
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(hasURL(sitemap, self.my_doc_url))
+
+    def test_regexp(self):
+        self.workflow.doActionFor(self.my_doc, 'publish')
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(not hasURL(sitemap, self.portal.absolute_url()))
+
+        regexp = "s/\/%s//"%self.my_doc.getId()
+        self.contentSM.setReg_exp([regexp])
+
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+        self.assert_(hasURL(sitemap, self.portal.absolute_url()))
+
+    def test_add_urls(self):
+        self.contentSM.setUrls(['http://w1', 'w2', '/w3'])
+        w1_url = 'http://w1'
+        w2_url = self.portal.absolute_url() + '/w2'
+        w3_url = self.portal.getPhysicalRoot().absolute_url() + '/w3'
+        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
+
+        self.assert_(hasURL(sitemap, w1_url))
+        self.assert_(hasURL(sitemap, w2_url))
+        self.assert_(hasURL(sitemap, w3_url))
+
+
+class TestPinging(FunctionalTestCase):
+
+    def afterSetUp(self):
+        super(TestPinging, self).afterSetUp()
+        self.workflow.setChainForPortalTypes(pt_names=('News Item','Document'),
+                                             chain="simple_publication_workflow")
+        self.gsm_props = self.portal.portal_properties['googlesitemap_properties']
+        # Add sitemaps
+        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
+        self.contentSM.setPingTransitions(('simple_publication_workflow#publish',))
+        self.newsSM = _createObjectByType('Sitemap', self.portal, id='news-sitemaps')
+        self.newsSM.setPortalTypes(('News Item','Document'))
+        self.newsSM.setPingTransitions(('simple_publication_workflow#publish',))
+        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps'
+        # Add testing document to portal
+        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc')
+        self.my_news = _createObjectByType('News Item', self.portal, id='my_news')
+
+    def testAutomatePinging(self):
+        # 1. Check for pinging both sitemaps
+        back_out, myout = sys.stdout, StringIO()
+        sys.stdout = myout
+        try:
+            self.workflow.doActionFor(self.my_doc, 'publish')
+            myout.seek(0)
+            data = myout.read()
+        finally:
+            sys.stdout = back_out
+
+        self.assert_('Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.contentSM.id, data))
+        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
+
+        # 2. Check for pinging only news-sitemap sitemaps
+        back_out, myout = sys.stdout, StringIO()
+        sys.stdout = myout
+        try:
+            self.workflow.doActionFor(self.my_news, 'publish')
+            myout.seek(0)
+            data = myout.read()
+        finally:
+            sys.stdout = back_out
+
+        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
+        self.assert_(not 'Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
+                     "Pinged %s on news: '%s'" % (self.contentSM.id, data))
+
+    def testPingingWithSetupForm(self):
+        # Ping news and content sitemaps
+        formUrl = '/'+self.portal.absolute_url(1) + '/prefs_gsm_settings'
+        qs = 'smselected:list=%s&smselected:list=%s&form.button.Ping=1&form.submitted=1' % \
+             (self.contentSM.id, self.newsSM.id)
+
+        back_out, myout = sys.stdout, StringIO()
+        sys.stdout = myout
+        try:
+            response = self.publish("%s?%s" % (formUrl, qs), basic=self.auth)
+            myout.seek(0)
+            data = myout.read()
+        finally:
+            sys.stdout = back_out
+
+        self.assert_('Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.contentSM.id, data))
+        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
+                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
+
+
+
+def test_suite():
+    from unittest import TestSuite, makeSuite
+    suite = TestSuite()
+    suite.addTest(makeSuite(TestSitemapType))
+    suite.addTest(makeSuite(TestSettings))
+    suite.addTest(makeSuite(TestPinging))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+#    framework()
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py	(revision 2523)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py	(revision 2538)
@@ -18,4 +18,5 @@
 
     def afterSetUp(self):
+        super(TestUpgrade, self).afterSetUp()
         self.setup = self.portal.portal_setup
         self.profile = "quintagroup.plonegooglesitemaps:default"
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testqPloneGoogleSitemaps.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testqPloneGoogleSitemaps.py	(revision 2523)
+++ 	(revision )
@@ -1,435 +1,0 @@
-#
-# Tests for quintagroup.plonegooglesitemaps
-#
-
-from base import *
-from cgi import FieldStorage
-from tempfile import TemporaryFile, NamedTemporaryFile
-
-from OFS.Image import cookId
-from Products.CMFPlone.utils import _createObjectByType
-from ZPublisher.HTTPRequest import FileUpload
-
-from zope.component import getSiteManager
-from archetypes.schemaextender.interfaces import ISchemaExtender
-
-def prepareUploadFile(prefix=""):
-    """ Helper function for prerare file to uploading """
-    fp = NamedTemporaryFile(mode='w+', prefix=prefix)
-    fp.write("google-site-verification: " + fp.name)
-    fp.seek(0,2)
-    fsize = fp.tell()
-    fp.seek(0)
-
-    env = {'REQUEST_METHOD':'PUT'}
-    headers = {'content-type':'text/plain',
-               'content-length': fsize,
-               'content-disposition':'attachment; filename=%s' % fp.name}
-    fs = FieldStorage(fp=fp, environ=env, headers=headers)
-    return FileUpload(fs), fp
-
-class TestGoogleSitemapsInstallation(TestCase):
-
-    def testType(self):
-        pt = self.portal.portal_types
-        self.assert_('Sitemap' in pt.objectIds(), 
-            'No "Sitemap" type after installation')
-        #Test views
-        views = pt.getTypeInfo('Sitemap').view_methods
-        self.assert_('sitemap.xml' in views, 
-            'No "sitemap.xml" view for Sitemap type')
-        self.assert_('mobile-sitemap.xml' in views, 
-            'No "mobile-sitemap.xml" view for Sitemap type')
-        self.assert_('news-sitemap.xml' in views, 
-            'No "news-sitemap.xml" view for Sitemap type')
-
-    def testGSMProperties(self):
-        pp = self.portal.portal_properties
-
-        # Test types_not_searched
-        self.assert_("Sitemap" in pp['site_properties'].getProperty('types_not_searched'), 
-            'No "Sitemap" added to types not searched on installation')
-        # Test metaTypesNotToList
-        self.assert_("Sitemap" in pp['navtree_properties'].getProperty('metaTypesNotToList'), 
-            'No "Sitemap" added to types not to list on installation')
-
-        # Test 'googlesitemap_properties'
-        self.assert_('googlesitemap_properties' in pp.objectIds(), 
-            'No "googlesitemap_properties" after installation')
-        qsmprops = pp['googlesitemap_properties']
-        self.assert_(qsmprops.hasProperty('verification_filenames'),
-            'No "verification_filenames" property added on installation')
-
-    def testSkins(self):
-        ps = self.portal.portal_skins
-        self.assert_('plonegooglesitemaps' in ps.objectIds(), 
-            'No "plonegooglesitemaps" skin layer in portal_skins')
-        self.assert_('plonegooglesitemaps' in ps.getSkinPath(ps.getDefaultSkin()),
-            'No "plonegooglesitemaps" skin layer in default skin')
-
-    def testConfiglet(self):
-        cp = self.portal.portal_controlpanel
-        self.assert_([1 for ai in cp.listActionInfos() if ai['id']=='GoogleSitemaps'], 
-            'No "GoogleSitemaps" configlet added to plone control panel')
-
-    def testNewsSchemaExtenderRegistered(self):
-        lsm = getSiteManager(self.portal)
-        news = self.portal.invokeFactory("News Item", id="test_news")
-        news = getattr(self.portal, "test_news")
-        self.assertNotEqual(lsm.queryAdapter(news, interface=ISchemaExtender), None)
-
-
-class TestGoogleSitemapsUninstallation(TestCase):
-
-    def afterSetUp(self):
-        self.loginAsPortalOwner()
-        qi = self.portal.portal_quickinstaller
-        qi.uninstallProducts(products=['quintagroup.plonegooglesitemaps',])
-        self._refreshSkinData()
-
-    def testNewsSchemaExtenderUnregistered(self):
-        lsm = getSiteManager(self.portal)
-        news = self.portal.invokeFactory("News Item", id="test_news")
-        news = getattr(self.portal, "test_news")
-        self.assertEqual(lsm.queryAdapter(news, interface=ISchemaExtender), None)
-
-
-class TestSitemapType(FunctionalTestCase):
-
-    def afterSetUp(self):
-        super(TestSitemapType, self).afterSetUp()
-        self.auth = 'admin:admin'
-        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
-        self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), [])
-
-    def testFields(self):
-        field_ids = map(lambda x:x.getName(), self.contentSM.Schema().fields())
-        # test old Sitemap settings fields
-        self.assert_('id' in field_ids)
-        self.assert_('portalTypes' in field_ids)
-        self.assert_('states' in field_ids)
-        self.assert_('blackout_list' in field_ids)
-        self.assert_('urls' in field_ids)
-        self.assert_('pingTransitions' in field_ids)
-        # test new sitemap type field
-        self.assert_('sitemapType' in field_ids)
-
-    def testSitemapTypes(self):
-        sitemap_types = self.contentSM.getField('sitemapType').Vocabulary().keys()
-        self.assert_('content' in sitemap_types)
-        self.assert_('mobile' in sitemap_types)
-        self.assert_('news' in sitemap_types)
-
-    def testAutoSetLayout(self):
-        response = self.publish('/%s/createObject?type_name=Sitemap' % \
-                                self.portal.absolute_url(1), basic=self.auth)
-        location = response.getHeader('location')
-        newurl = location[location.find('/'+self.portal.absolute_url(1)):]
-
-        msm_id = 'mobile_sitemap'
-        form = {'id': msm_id,
-                'sitemapType':'mobile',
-                'portalTypes':['Document',],
-                'states':['published'],
-                'form_submit':'Save',
-                'form.submitted':1,
-                }
-        post_data = StringIO(urlencode(form))
-        response = self.publish(newurl, request_method='POST', stdin=post_data, basic=self.auth)
-        msitemap = getattr(self.portal, msm_id)
-
-        self.assertEqual(msitemap.defaultView(), 'mobile-sitemap.xml')
-
-    def txestPingSetting(self):
-        pwf = self.portal.portal_workflow['plone_workflow']
-        self.assertEqual(self.contentSM.getPingTransitions(), ())
-
-        self.contentSM.setPingTransitions(('plone_workflow#publish',))
-        self.assertEqual(self.contentSM.getPingTransitions(), ('plone_workflow#publish',))
-        self.assert_(ping_googlesitemap in pwf.scripts.keys(),"Not add wf script")
-
-
-class TestGoogleSitemaps(FunctionalTestCase):
-
-    def afterSetUp(self):
-        super(TestGoogleSitemaps, self).afterSetUp()
-
-        self.workflow = self.portal.portal_workflow
-        self.auth = 'admin:admin'
-        _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
-        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps'
-        self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), [])
-        self.gsm_props = self.portal.portal_properties['googlesitemap_properties']
-
-        # Add testing document to portal
-        my_doc = self.portal.invokeFactory('Document', id='my_doc')
-        self.my_doc = self.portal['my_doc']
-        self.my_doc.edit(text_format='plain', text='hello world')
-
-
-    def testSitemap(self):
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        parsed_sitemap = parse(sitemap)
-        start = parsed_sitemap['start']
-        data = parsed_sitemap['data']
-        self.assert_('urlset' in start.keys())
-        self.assertFalse(self.my_doc.absolute_url(0) in data,
-                         'Wrong content present in the sitemap')
-
-        self.workflow.doActionFor(self.my_doc, 'publish')
-
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        parsed_sitemap = parse(sitemap)
-        start = parsed_sitemap['start']
-        data = parsed_sitemap['data']
-        self.assertEqual(len(start.keys()), 4)
-        self.assert_('urlset' in start.keys())
-        self.assert_('url' in start.keys())
-        self.assert_('loc' in start.keys())
-        self.assert_('lastmod' in start.keys())
-
-        self.assertTrue(self.my_doc.absolute_url(0) in data, 'Incorect url')
-
-    def testVerificationFileCreation(self):
-        fp, fname = None, None
-        try:
-            fupload, fp = prepareUploadFile()
-            fname, ftitle = cookId('', '', fupload)
-            self.portal.REQUEST.form['verification_file'] = fupload
-            self.portal.gsm_create_verify_file()
-        finally:
-            if fp: fp.close()
-        vf_created = hasattr(self.portal, fname)
-        self.assert_(vf_created, 'Verification file not created')
-
-    def testVerificationForm(self):
-        verifyConfigUrl = '/'+self.portal.absolute_url(1) + '/prefs_gsm_verification'
-        verif_config = self.publish(verifyConfigUrl, self.auth).getBody()
-        rexp_input_acitve = re.compile('<input\s+name="verification_file"\s+([^>]*)>', re.I|re.S)
-        rexp_button_acitve = re.compile('<input\s+name="form.button.CreateFile"\s+([^>]*)>', re.I|re.S)
-        rexp_delete_button = re.compile('<input\s+name="form.button.DeleteFile"\s+[^>]*>', re.I|re.S)
-
-        input_acitve = rexp_input_acitve.search(verif_config)
-        button_acitve = rexp_button_acitve.search(verif_config)
-        delete_button = rexp_delete_button.match(verif_config)
-
-        self.assert_(input_acitve and not 'disabled' in input_acitve.groups(1))
-        self.assert_(button_acitve and not 'disabled' in button_acitve.groups(1))
-        self.assert_(not delete_button)
-
-        fp, fname = None, None
-        try:
-            fupload, fp = prepareUploadFile()
-            fname, ftitle = cookId('', '', fupload)
-            self.portal.REQUEST.form['verification_file'] = fupload
-            self.portal.gsm_create_verify_file()
-        finally:
-            if fp: fp.close()
-
-        input_acitve = rexp_input_acitve.search(verif_config)
-        button_acitve = rexp_button_acitve.search(verif_config)
-        delete_button = rexp_delete_button.match(verif_config)
-
-        verif_config = self.publish(verifyConfigUrl, self.auth).getBody()
-        self.assert_(input_acitve and not 'disabled' in input_acitve.groups(1))
-        self.assert_(not delete_button)
-
-    def testMultiplyVerificationFiles(self):
-        verifyConfigUrl = '/'+self.portal.absolute_url(1) + '/prefs_gsm_verification'
-        fnames = []
-        for i in [1,2]:
-            fp, fname, response = None, None, None
-            try:
-                fupload, fp = prepareUploadFile(prefix=str(i))
-                fname, ftitle = cookId('', '', fupload)
-                form = {'form.button.CreateFile': 'Create verification file',
-                        'form.submitted': 1}
-                extra_update = {'verification_file': fupload}
-                response = self.publish(verifyConfigUrl, request_method='POST',
-                                        stdin=StringIO(urlencode(form)),
-                                        basic=self.auth, extra=extra_update)
-            finally:
-                if fp: fp.close()
-            
-            self.assertEqual(response.getStatus(), 200)
-            self.assert_(fname in self.gsm_props.getProperty('verification_filenames',[]),
-                             self.gsm_props.getProperty('verification_filenames',[]))
-            fnames.append(fname)
-
-        self.assertEqual(len([1 for vf in fnames \
-            if vf in self.gsm_props.getProperty('verification_filenames',[])]), 2,
-            self.gsm_props.getProperty('verification_filenames',[]))
-
-
-class TestSettings(FunctionalTestCase):
-
-    def afterSetUp(self):
-        super(TestSettings, self).afterSetUp()
-
-        self.workflow = self.portal.portal_workflow
-        self.gsm_props = self.portal.portal_properties['googlesitemap_properties']
-        self.auth = 'admin:admin'
-        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
-
-        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps'
-
-        self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), [])
-
-        # Add testing document to portal
-        my_doc = self.portal.invokeFactory('Document', id='my_doc')
-        self.my_doc = self.portal['my_doc']
-        self.my_doc.edit(text_format='plain', text='hello world')
-        self.my_doc_url = self.my_doc.absolute_url()
-
-    def testMetaTypeToDig(self):
-        self.workflow.doActionFor(self.my_doc, 'publish')
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(hasURL(sitemap, self.my_doc_url))
-
-        self.contentSM.setPortalTypes([])
-
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(not hasURL(sitemap, self.my_doc_url))
-
-        self.contentSM.setPortalTypes(['Document'])
-
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(hasURL(sitemap, self.my_doc_url))
-
-    def testStates(self):
-        self.workflow.doActionFor(self.my_doc, 'publish')
-        self.contentSM.setStates(['visible'])
-
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(not hasURL(sitemap, self.my_doc_url))
-
-        self.contentSM.setStates(['published'])
-
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(hasURL(sitemap, self.my_doc_url))
-
-    def test_blackout_entries(self):
-        self.workflow.doActionFor(self.my_doc, 'publish')
-        self.contentSM.setBlackout_list((self.my_doc.getId(),))
-
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(not hasURL(sitemap, self.my_doc_url))
-
-        self.contentSM.setBlackout_list([])
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(hasURL(sitemap, self.my_doc_url))
-
-    def test_regexp(self):
-        self.workflow.doActionFor(self.my_doc, 'publish')
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(not hasURL(sitemap, self.portal.absolute_url()))
-
-        regexp = "s/\/%s//"%self.my_doc.getId()
-        self.contentSM.setReg_exp([regexp])
-
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-        self.assert_(hasURL(sitemap, self.portal.absolute_url()))
-
-    def test_add_urls(self):
-        self.contentSM.setUrls(['http://w1', 'w2', '/w3'])
-        w1_url = 'http://w1'
-        w2_url = self.portal.absolute_url() + '/w2'
-        w3_url = self.portal.getPhysicalRoot().absolute_url() + '/w3'
-        sitemap = self.publish(self.sitemapUrl, self.auth).getBody()
-
-        self.assert_(hasURL(sitemap, w1_url))
-        self.assert_(hasURL(sitemap, w2_url))
-        self.assert_(hasURL(sitemap, w3_url))
-
-
-class TestPinging(FunctionalTestCase):
-
-    def afterSetUp(self):
-        super(TestPinging, self).afterSetUp()
-
-        self.workflow = self.portal.portal_workflow
-        self.workflow.setChainForPortalTypes(pt_names=('News Item','Document'),
-                                             chain="simple_publication_workflow")
-        self.gsm_props = self.portal.portal_properties['googlesitemap_properties']
-        self.auth = 'admin:admin'
-        self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), [])
-        # Add sitemaps
-        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps')
-        self.contentSM.setPingTransitions(('simple_publication_workflow#publish',))
-        self.newsSM = _createObjectByType('Sitemap', self.portal, id='news-sitemaps')
-        self.newsSM.setPortalTypes(('News Item','Document'))
-        self.newsSM.setPingTransitions(('simple_publication_workflow#publish',))
-        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps'
-        # Add testing document to portal
-        my_doc = self.portal.invokeFactory('Document', id='my_doc')
-        self.my_doc = self.portal['my_doc']
-        my_news = self.portal.invokeFactory('News Item', id='my_news')
-        self.my_news = self.portal['my_news']
-
-    def testAutomatePinging(self):
-        # 1. Check for pinging both sitemaps
-        back_out, myout = sys.stdout, StringIO()
-        sys.stdout = myout
-        try:
-            self.workflow.doActionFor(self.my_doc, 'publish')
-            myout.seek(0)
-            data = myout.read()
-        finally:
-            sys.stdout = back_out
-
-        self.assert_('Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
-                     "Not pinged %s: '%s'" % (self.contentSM.id, data))
-        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
-                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
-
-        # 2. Check for pinging only news-sitemap sitemaps
-        back_out, myout = sys.stdout, StringIO()
-        sys.stdout = myout
-        try:
-            self.workflow.doActionFor(self.my_news, 'publish')
-            myout.seek(0)
-            data = myout.read()
-        finally:
-            sys.stdout = back_out
-
-        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
-                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
-        self.assert_(not 'Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
-                     "Pinged %s on news: '%s'" % (self.contentSM.id, data))
-
-    def testPingingWithSetupForm(self):
-        # Ping news and content sitemaps
-        formUrl = '/'+self.portal.absolute_url(1) + '/prefs_gsm_settings'
-        qs = 'smselected:list=%s&smselected:list=%s&form.button.Ping=1&form.submitted=1' % \
-             (self.contentSM.id, self.newsSM.id)
-
-        back_out, myout = sys.stdout, StringIO()
-        sys.stdout = myout
-        try:
-            response = self.publish("%s?%s" % (formUrl, qs), basic=self.auth)
-            myout.seek(0)
-            data = myout.read()
-        finally:
-            sys.stdout = back_out
-
-        self.assert_('Pinged %s sitemap to Google' % self.contentSM.absolute_url() in data,
-                     "Not pinged %s: '%s'" % (self.contentSM.id, data))
-        self.assert_('Pinged %s sitemap to Google' % self.newsSM.absolute_url() in data,
-                     "Not pinged %s: '%s'" % (self.newsSM.id, data))
-
-
-
-def test_suite():
-    from unittest import TestSuite, makeSuite
-    suite = TestSuite()
-    suite.addTest(makeSuite(TestGoogleSitemapsInstallation))
-    suite.addTest(makeSuite(TestGoogleSitemapsUninstallation))
-    suite.addTest(makeSuite(TestSitemapType))
-    suite.addTest(makeSuite(TestGoogleSitemaps))
-    suite.addTest(makeSuite(TestSettings))
-    suite.addTest(makeSuite(TestPinging))
-    return suite
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
-#    framework()
