Changeset 2534 in products


Ignore:
Timestamp:
Jun 15, 2010 6:36:40 PM (11 years ago)
Author:
mylan
Message:

#206: some cleanup, simplify tests

Location:
quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/base.py

    r2394 r2534  
    3030 
    3131 
    32 class MixinTestCase: 
     32class MixinTestCase(object): 
    3333    """ Define layer and common afterSetup method with package installation. 
    3434        Package installation on plone site setup impossible because of 
     
    3939    def afterSetUp(self): 
    4040        self.loginAsPortalOwner() 
     41        self.workflow = self.portal.portal_workflow 
    4142 
    4243 
     
    4445    """ For unit tests """ 
    4546 
     47 
    4648class FunctionalTestCase(MixinTestCase, ptc.FunctionalTestCase): 
    4749    """ For functional tests """ 
     50 
     51    def afterSetUp(self): 
     52        super(FunctionalTestCase, self).afterSetUp() 
     53        self.auth = "%s:%s" % (portal_owner, default_password) 
    4854 
    4955# Initialize all needed zcml directives 
  • quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/testConfiglet.py

    r2531 r2534  
    1616    def afterSetUp(self): 
    1717        super(TestConfigletSettings, self).afterSetUp() 
    18         self.auth = "%s:%s" % (portal_owner, default_password) 
    1918        self.settingsURL = '/'+self.portal.absolute_url(1) + '/prefs_gsm_settings' 
    2019 
     
    7069    def afterSetUp(self): 
    7170        super(TestConfigletOverview, self).afterSetUp() 
    72         self.auth = "%s:%s" % (portal_owner, default_password) 
    7371        self.overviewURL = '/'+self.portal.absolute_url(1) + '/prefs_gsm_overview' 
    7472        self.smURL = "%s/sitemap.xml" % self.portal.absolute_url() 
  • quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/testGoogleSitemaps.py

    r2530 r2534  
    3333        super(TestGoogleSitemaps, self).afterSetUp() 
    3434 
    35         self.workflow = self.portal.portal_workflow 
    36         self.auth = 'admin:admin' 
    3735        _createObjectByType('Sitemap', self.portal, id='google-sitemaps') 
    3836        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps' 
    39         self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), []) 
    4037        self.gsm_props = self.portal.portal_properties['googlesitemap_properties'] 
    4138 
    4239        # Add testing document to portal 
    43         my_doc = self.portal.invokeFactory('Document', id='my_doc') 
    44         self.my_doc = self.portal['my_doc'] 
     40        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc') 
    4541        self.my_doc.edit(text_format='plain', text='hello world') 
    46  
    4742 
    4843    def testSitemap(self): 
  • quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/testInstallation.py

    r2527 r2534  
    5959    def afterSetUp(self): 
    6060        self.loginAsPortalOwner() 
    61         qi = self.portal.portal_quickinstaller 
    62         qi.uninstallProducts(products=['quintagroup.plonegooglesitemaps',]) 
     61        self.portal.portal_quickinstaller.uninstallProducts( 
     62            products=['quintagroup.plonegooglesitemaps',]) 
    6363        self._refreshSkinData() 
    6464 
  • quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/testMobileSitemaps.py

    r2529 r2534  
    2929        # Add testing mobile item to portal 
    3030        self.pubdate = (DateTime()+1).strftime("%Y-%m-%d") 
    31         my_mobile = self.portal.invokeFactory("Document", id="my_mobile") 
    32         self.my_mobile = self.portal["my_mobile"] 
     31        self.my_mobile = _createObjectByType('Document', self.portal, id='my_mobile') 
    3332        alsoProvides(self.my_mobile, IMobileMarker) 
    3433        self.my_mobile.edit(text="Test mobile item", title="First mobile (test)", 
    3534                            effectiveDate=self.pubdate) 
    36         self.portal.portal_workflow.doActionFor(self.my_mobile, "publish") 
     35        self.workflow.doActionFor(self.my_mobile, "publish") 
    3736        self.reParse() 
    3837 
  • quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py

    r2422 r2534  
    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/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/testPinging.py

    r2527 r2534  
    77    def afterSetUp(self): 
    88        super(TestPinging, self).afterSetUp() 
    9  
    10         self.workflow = self.portal.portal_workflow 
    119        self.workflow.setChainForPortalTypes(pt_names=('News Item','Document'), 
    1210                                             chain="simple_publication_workflow") 
    1311        self.gsm_props = self.portal.portal_properties['googlesitemap_properties'] 
    14         self.auth = 'admin:admin' 
    15         self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), []) 
    1612        # Add sitemaps 
    1713        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps') 
     
    2218        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps' 
    2319        # Add testing document to portal 
    24         my_doc = self.portal.invokeFactory('Document', id='my_doc') 
    25         self.my_doc = self.portal['my_doc'] 
    26         my_news = self.portal.invokeFactory('News Item', id='my_news') 
    27         self.my_news = self.portal['my_news'] 
     20        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc') 
     21        self.my_news = _createObjectByType('News Item', self.portal, id='my_news') 
    2822 
    2923    def testAutomatePinging(self): 
  • quintagroup.plonegooglesitemaps/branches/test_refactoring/quintagroup/plonegooglesitemaps/tests/testSitemaps.py

    r2533 r2534  
    1111    def afterSetUp(self): 
    1212        super(TestSitemapType, self).afterSetUp() 
    13         self.auth = 'admin:admin' 
    1413        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps') 
    15         self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), []) 
    1614 
    1715    def testFields(self): 
     
    5452 
    5553    def txestPingSetting(self): 
    56         pwf = self.portal.portal_workflow['plone_workflow'] 
     54        pwf = self.workflow['plone_workflow'] 
    5755        self.assertEqual(self.contentSM.getPingTransitions(), ()) 
    5856 
     
    7674    def afterSetUp(self): 
    7775        super(TestSettings, self).afterSetUp() 
    78  
    79         self.workflow = self.portal.portal_workflow 
    8076        self.gsm_props = self.portal.portal_properties['googlesitemap_properties'] 
    81         self.auth = 'admin:admin' 
    8277        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps') 
    83  
    8478        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps' 
    85  
    86         self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), []) 
    87  
    8879        # Add testing document to portal 
    89         my_doc = self.portal.invokeFactory('Document', id='my_doc') 
    90         self.my_doc = self.portal['my_doc'] 
     80        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc') 
    9181        self.my_doc.edit(text_format='plain', text='hello world') 
    9282        self.my_doc_url = self.my_doc.absolute_url() 
     
    157147    def afterSetUp(self): 
    158148        super(TestPinging, self).afterSetUp() 
    159  
    160         self.workflow = self.portal.portal_workflow 
    161149        self.workflow.setChainForPortalTypes(pt_names=('News Item','Document'), 
    162150                                             chain="simple_publication_workflow") 
    163151        self.gsm_props = self.portal.portal_properties['googlesitemap_properties'] 
    164         self.auth = 'admin:admin' 
    165         self.portal.portal_membership.addMember('admin', 'admin', ('Manager',), []) 
    166152        # Add sitemaps 
    167153        self.contentSM = _createObjectByType('Sitemap', self.portal, id='google-sitemaps') 
     
    172158        self.sitemapUrl = '/'+self.portal.absolute_url(1) + '/google-sitemaps' 
    173159        # Add testing document to portal 
    174         my_doc = self.portal.invokeFactory('Document', id='my_doc') 
    175         self.my_doc = self.portal['my_doc'] 
    176         my_news = self.portal.invokeFactory('News Item', id='my_news') 
    177         self.my_news = self.portal['my_news'] 
     160        self.my_doc = _createObjectByType('Document', self.portal, id='my_doc') 
     161        self.my_news = _createObjectByType('News Item', self.portal, id='my_news') 
    178162 
    179163    def testAutomatePinging(self): 
Note: See TracChangeset for help on using the changeset viewer.