Index: /qPloneGoogleSitemaps/branches/contenttype/config.py
===================================================================
--- /qPloneGoogleSitemaps/branches/contenttype/config.py	(revision 453)
+++ /qPloneGoogleSitemaps/branches/contenttype/config.py	(revision 454)
@@ -16,4 +16,5 @@
 
 ping_googlesitemap = 'pingGoogleSitemap'
+testing = 0
 
 AVAILABLE_WF_SCRIPTS = [ping_googlesitemap, '']
Index: /qPloneGoogleSitemaps/branches/contenttype/handlers.py
===================================================================
--- /qPloneGoogleSitemaps/branches/contenttype/handlers.py	(revision 453)
+++ /qPloneGoogleSitemaps/branches/contenttype/handlers.py	(revision 454)
@@ -14,7 +14,8 @@
         plone_home = getToolByName(object, 'portal_url').getPortalObject().absolute_url()
         wftrans_name = "%s#%s" % (event.workflow.id, event.transition.id)
+        obj_ptype = object.portal_type
         for sm in sitemaps:
-            if wftrans_name in sm.getPingTransitions():
+            if wftrans_name in sm.getPingTransitions() \
+               and obj_ptype in sm.getPortalTypes():
                 ping_google(plone_home, sm.id)
-                print "Pinged %s sitemap to google" % sm.id
     return 0
Index: /qPloneGoogleSitemaps/branches/contenttype/tests/testqPloneGoogleSitemaps.py
===================================================================
--- /qPloneGoogleSitemaps/branches/contenttype/tests/testqPloneGoogleSitemaps.py	(revision 453)
+++ /qPloneGoogleSitemaps/branches/contenttype/tests/testqPloneGoogleSitemaps.py	(revision 454)
@@ -2,5 +2,5 @@
 # Tests for qPloneGoogleSitemaps
 #
-import re
+import re, sys
 from urllib import urlencode
 from StringIO import StringIO
@@ -16,4 +16,5 @@
 
 from XMLParser import parse, hasURL
+Products.qPloneGoogleSitemaps.config.testing = 1
 
 PRODUCT = 'qPloneGoogleSitemaps'
@@ -190,7 +191,7 @@
         rexp_delete_button = re.compile('<input\s+name="form.button.DeleteFile"\s+[^>]*>', re.I|re.S)
 
-        input_acitve = rexp_input_acitve(verif_config)
-        button_acitve = rexp_button_acitve(verif_config)
-        delete_button = rexp_delete_button(verif_config)
+        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))
@@ -200,7 +201,7 @@
         self.portal.gsm_create_verify_file('verif_file')
 
-        input_acitve = rexp_input_acitve(verif_config)
-        button_acitve = rexp_button_acitve(verif_config)
-        delete_button = rexp_delete_button(verif_config)
+        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()
@@ -314,4 +315,71 @@
 
 
+class TestPinging(PloneTestCase.FunctionalTestCase):
+
+    def afterSetUp(self):
+        self.loginAsPortalOwner()
+
+        self.workflow = self.portal.portal_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(('plone_workflow#publish',))
+        self.newsSM = _createObjectByType('Sitemap', self.portal, id='news-sitemaps')
+        self.newsSM.setPortalTypes(('News Item','Document'))
+        self.newsSM.setPingTransitions(('plone_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
+        self.workflow.doActionFor(self.my_doc, 'publish')
+        myout.seek(0)
+        data = myout.read()
+        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
+        self.workflow.doActionFor(self.my_news, 'publish')
+        myout.seek(0)
+        data = myout.read()
+        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
+        response = self.publish("%s?%s" % (formUrl, qs), basic=self.auth)
+        myout.seek(0)
+        data = myout.read()
+        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():
@@ -322,4 +390,5 @@
     suite.addTest(makeSuite(TestqPloneGoogleSitemaps))
     suite.addTest(makeSuite(TestSettings))
+    suite.addTest(makeSuite(TestPinging))
 
     return suite
Index: /qPloneGoogleSitemaps/branches/contenttype/utils.py
===================================================================
--- /qPloneGoogleSitemaps/branches/contenttype/utils.py	(revision 453)
+++ /qPloneGoogleSitemaps/branches/contenttype/utils.py	(revision 454)
@@ -4,9 +4,14 @@
 from OFS.ObjectManager import BadRequestException
 
+from Products.qPloneGoogleSitemaps.config import testing
+
 def ping_google(url, sitemap_id):
     """Ping sitemap to Google"""
-    sitemap_url = urlquote(url + "/" + sitemap_id)
+    resurl = url + "/" + sitemap_id
+    sitemap_url = urlquote(resurl)
     g = urlopen('http://www.google.com/webmasters/sitemaps/ping?sitemap='+sitemap_url)
     result = g.read()
     g.close()
+    if testing:
+        print "Pinged %s sitemap to google" % resurl
     return 0
