Changeset 2538 in products


Ignore:
Timestamp:
Jun 16, 2010 2:28:02 PM (9 years ago)
Author:
mylan
Message:

Merged revisions 3566-3575 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.plonegooglesitemaps/branches/test_refactoring

........

r3566 | mylan | 2010-06-14 12:24:52 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Split single testqPloneGoogleSitemaps module into several specific one

........

r3567 | mylan | 2010-06-14 16:14:34 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Improve code coverage - remove useless BBB code from interfaces.

........

r3568 | mylan | 2010-06-14 20:24:25 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Improve code coverage - added test for MobileSitemap?, MobileSitemapView?.

........

r3569 | mylan | 2010-06-14 22:39:39 +0300 (Mon, 14 Jun 2010) | 1 line


#206: reorganize sitemap tests

........

r3570 | mylan | 2010-06-14 22:40:12 +0300 (Mon, 14 Jun 2010) | 1 line


#206: Added configlet tests

........

r3571 | mylan | 2010-06-14 23:05:19 +0300 (Mon, 14 Jun 2010) | 1 line


#206: remove BBB code for plone<3.0

........

r3572 | mylan | 2010-06-14 23:12:00 +0300 (Mon, 14 Jun 2010) | 1 line


#206: added workflow vocabularies tests for SitemapTypes?

........

r3573 | mylan | 2010-06-15 21:36:40 +0300 (Tue, 15 Jun 2010) | 1 line


#206: some cleanup, simplify tests

........

r3574 | mylan | 2010-06-16 16:35:31 +0300 (Wed, 16 Jun 2010) | 1 line


#206: move mobile sitemap code preparation into base module

........

r3575 | mylan | 2010-06-16 16:37:14 +0300 (Wed, 16 Jun 2010) | 1 line


#206: Added security tests

........

Location:
quintagroup.plonegooglesitemaps/trunk
Files:
1 deleted
8 edited
7 copied

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/trunk

    • Property svnmerge-integrated changed from /quintagroup.plonegooglesitemaps/branches/test_refactoring:1-3563 to /quintagroup.plonegooglesitemaps/branches/test_refactoring:1-3576
    • Property svn:mergeinfo set to /quintagroup.plonegooglesitemaps/branches/test_refactoring:2527-2536
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/browser/configletview.py

    r2520 r2538  
    102102        return sitemaps 
    103103 
    104  
    105104    def sitemapsDict(self): 
    106105        content, mobile, news = [],[],[] 
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/config.py

    r1729 r2538  
    2020AVAILABLE_WF_SCRIPTS = [ping_googlesitemap, ''] 
    2121 
    22 try: 
    23     from Products.DCWorkflow.events import AfterTransitionEvent 
    24 except ImportError: 
    25     IS_PLONE_3 = False 
    26 else: 
    27     IS_PLONE_3 = True 
    28  
    2922# Turn-ON/OFF portal_catalog 
    3023# updating on product installation 
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/sitemap.py

    r2406 r2538  
    158158        """ 
    159159        self.getField('pingTransitions').set(self, value) 
    160         if not IS_PLONE_3: 
    161             # Update Workflow if needed 
    162             pw = getToolByName(self, 'portal_workflow') 
    163             #ping_googlesitemap = PING_EMETHODS_MAP[self.getSitemapType()] 
    164             transmap = {} 
    165             for key in value: 
    166                 if key.find('#')>0: 
    167                     ids = key.split('#') 
    168                     wfid = ids[0] 
    169                     if not wfid in transmap.keys(): 
    170                         transmap[wfid]=[] 
    171                     transmap[wfid].append(ids[1]) 
    172             for wfid in transmap.keys(): 
    173                 workflow = pw.getWorkflowById(wfid) 
    174                 if ping_googlesitemap not in workflow.scripts.objectIds(): 
    175                     workflow.scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod( 
    176                         ping_googlesitemap, 
    177                         'Ping sitemap', 
    178                         'quintagroup.plonegooglesitemaps.ping_googlesitemap', 
    179                         ping_googlesitemap) 
    180                 transitions_set = transmap[wfid] 
    181                 for transition in workflow.transitions.values(): 
    182                     trid = transition.id 
    183                     tras = transition.after_script_name 
    184                     if (tras == '') and (trid in transitions_set): 
    185                         #set 
    186                         after_script = ping_googlesitemap 
    187                     elif (tras == ping_googlesitemap) and not (trid in transitions_set): 
    188                         #reset 
    189                         after_script = '' 
    190                     else: 
    191                         #avoid properties set 
    192                         continue 
    193                     transition.setProperties(title=transition.title, 
    194                         new_state_id=transition.new_state_id, 
    195                         after_script_name=after_script, 
    196                         actbox_name=transition.actbox_name) 
    197160 
    198161atapi.registerType(Sitemap, PROJECTNAME) 
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/interfaces.py

    r1593 r2538  
    44from zope.app.container.constraints import contains 
    55from zope.app.container.constraints import containers 
     6 
     7from Products.DCWorkflow.interfaces import IAfterTransitionEvent 
    68 
    79from quintagroup.plonegooglesitemaps import qPloneGoogleSitemapsMessageFactory as _ 
     
    1113class ISitemap(Interface): 
    1214    """Search engine Sitemap content type""" 
    13  
    14 try: 
    15     from Products.DCWorkflow.interfaces import IAfterTransitionEvent 
    16 except ImportError: 
    17     # Copy IAfterTransitionEvent from Plone-3/Products.DCWorkflow.interfaces 
    18     from zope.interface import Interface, Attribute 
    19     from zope.app.event.interfaces import IObjectEvent 
    20  
    21     class ITransitionEvent(IObjectEvent): 
    22         """An event that's fired upon a workflow transition. 
    23         """ 
    24  
    25         workflow = Attribute(u"The workflow definition triggering the transition") 
    26         old_state = Attribute(u"The state definition of the workflow state before the transition") 
    27         new_state = Attribute(u"The state definition of the workflow state before after transition") 
    28         transition = Attribute(u"The transition definition taking place. " 
    29                                 "May be None if this is the 'transition' to the initial state.") 
    30         status = Attribute(u"The status dict of the object.") 
    31         kwargs = Attribute(u"Any keyword arguments passed to doActionFor() when the transition was invoked") 
    32  
    33     class IAfterTransitionEvent(ITransitionEvent): 
    34  
    35         """An event that's fired after a workflow transition. 
    36         """ 
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py

    r2394 r2538  
    99 
    1010from zope.testing import doctestunit 
     11from zope.interface import Interface 
    1112from zope.component import testing 
    1213from Testing import ZopeTestCase as ztc 
     
    2526from quintagroup.plonegooglesitemaps.config import PROJECTNAME 
    2627from quintagroup.plonegooglesitemaps.config import ping_googlesitemap 
     28from quintagroup.plonegooglesitemaps.browser import mobilesitemapview 
    2729 
    2830quintagroup.plonegooglesitemaps.config.testing = 1 
     
    3032 
    3133 
    32 class MixinTestCase: 
     34class IMobileMarker(Interface): 
     35    """Test Marker interface for mobile objects""" 
     36 
     37 
     38class MixinTestCase(object): 
    3339    """ Define layer and common afterSetup method with package installation. 
    3440        Package installation on plone site setup impossible because of 
     
    3945    def afterSetUp(self): 
    4046        self.loginAsPortalOwner() 
     47        self.workflow = self.portal.portal_workflow 
     48        self.orig_mobile_ifaces = None 
     49 
     50    def patchMobile(self): 
     51        # patch mobile sitemap view 
     52        self.orig_mobile_ifaces = mobilesitemapview.MOBILE_INTERFACES 
     53        mobilesitemapview.MOBILE_INTERFACES = [IMobileMarker.__identifier__,] 
     54 
     55    def beforeTearDown(self): 
     56        if self.orig_mobile_ifaces is not None: 
     57            mobilesitemapview.MOBILE_INTERFACES = self.orig_mobile_ifaces 
    4158 
    4259 
     
    4461    """ For unit tests """ 
    4562 
     63 
    4664class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase): 
    4765    """ For functional tests """ 
     66 
     67    def afterSetUp(self): 
     68        super(FunctionalTestCase, self).afterSetUp() 
     69        self.auth = "%s:%s" % (portal_owner, default_password) 
    4870 
    4971# Initialize all needed zcml directives 
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py

    r2422 r2538  
    1717        # Add testing news item to portal 
    1818        self.pubdate = (DateTime()+1).strftime("%Y-%m-%d") 
    19         my_news = self.portal.invokeFactory("News Item", id="my_news") 
    20         self.my_news = self.portal["my_news"] 
     19        self.my_news = _createObjectByType('News Item', self.portal, id='my_news') 
    2120        self.my_news.edit(text="Test news item", title="First news (test)", language="ua", 
    2221                          effectiveDate=self.pubdate, gsm_access="Registration", 
    2322                          gsm_genres=("PressRelease",), gsm_stock="NASDAQ:AMAT, BOM:500325") 
    24         self.portal.portal_workflow.doActionFor(self.my_news, "publish") 
     23        self.workflow.doActionFor(self.my_news, "publish") 
    2524        self.reParse() 
    2625 
     
    9190    def test_ngenresForNotExtended(self): 
    9291        # No genres should present for not extended content type 
    93         self.portal.invokeFactory("Document", id="my_doc") 
    94         my_doc = getattr(self.portal, "my_doc") 
     92        my_doc = _createObjectByType('Document', self.portal, id='my_doc') 
     93        #self.portal.invokeFactory("Document", id="my_doc") 
     94        #my_doc = getattr(self.portal, "my_doc") 
    9595        my_doc.edit(text="Test document") 
    96         self.portal.portal_workflow.doActionFor(my_doc, "publish") 
     96        self.workflow.doActionFor(my_doc, "publish") 
    9797        self.portal["news-sitemaps"].edit(portalTypes=("Document",)) 
    9898        self.reParse() 
     
    116116        # Add minimal testing news item to portal 
    117117        self.pubdate = (DateTime()+1).strftime("%Y-%m-%d") 
    118         my_news = self.portal.invokeFactory("News Item", id="my_news") 
    119         self.my_news = self.portal["my_news"] 
     118        self.my_news = _createObjectByType('News Item', self.portal, id='my_news') 
    120119        self.my_news.edit(effectiveDate=self.pubdate) 
    121         self.portal.portal_workflow.doActionFor(self.my_news, "publish") 
     120        self.workflow.doActionFor(self.my_news, "publish") 
    122121        self.reParse() 
    123122 
     
    168167    def afterSetUp(self): 
    169168        super(TestSchemaExtending, self).afterSetUp() 
    170         self.loginAsPortalOwner() 
    171         # Add testing news item to portal 
    172         my_news = self.portal.invokeFactory("News Item", id="my_news") 
    173         self.my_news = self.portal["my_news"] 
    174         my_doc = self.portal.invokeFactory("Document", id="my_doc") 
    175         self.my_doc = self.portal["my_doc"] 
     169        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc') 
     170        self.my_news = _createObjectByType('News Item', self.portal, id='my_news') 
    176171 
    177172    def testExtendNewsItemByDefault(self): 
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py

    r2423 r2538  
    1818 
    1919    def afterSetUp(self): 
     20        super(TestUpgrade, self).afterSetUp() 
    2021        self.setup = self.portal.portal_setup 
    2122        self.profile = "quintagroup.plonegooglesitemaps:default" 
Note: See TracChangeset for help on using the changeset viewer.