Changeset 1849 in products


Ignore:
Timestamp:
Mar 4, 2010 9:00:53 PM (14 years ago)
Author:
liebster
Message:

Add test migration

Location:
quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests/browser.txt

    r1833 r1849  
    5353=============================== 
    5454 
     55    >>> self.qi = self.portal.portal_quickinstaller 
     56    >>> self.sp = self.portal.portal_properties.seo_properties 
     57    >>> self.object_tabs = self.portal.portal_actions.object 
     58    >>> self.ps = self.portal.portal_setup 
     59 
    5560First uninstall product, if it is already installed: 
    5661 
    5762    >>> from quintagroup.seoptimizer.config import PROJECT_NAME 
    58     >>> self.qi = self.portal.portal_quickinstaller 
    5963    >>> if self.qi.isProductInstalled(PROJECT_NAME): 
    6064    ...     self.qi.uninstallProducts([PROJECT_NAME,]) 
     
    6872    >>> self.qi.installProduct(PROJECT_NAME) 
    6973    'Ran all install steps.' 
    70     >>> self.sp = self.portal.portal_properties.seo_properties 
    71     >>> self.object_tabs = self.portal.portal_actions.object 
    7274    >>> self.portal.portal_actions.object.get('SEOProperties', None) is not None 
    7375    True 
     
    9092 
    9193Test reinstallation 'SEO Properties' action 
     94For perform all upgrade steps on re-installation, earlier version of profile must be set. 
    9295 
    9396    >>> browser.open('http://nohost/plone/front-page') 
    9497    >>> "SEO Properties" in browser.contents 
    9598    False 
     99    >>> self.ps.setLastVersionForProfile('quintagroup.seoptimizer:default', '2.0.0') 
    96100    >>> self.qi.reinstallProducts((PROJECT_NAME,)) 
    97101    >>> self.portal.portal_actions.object.get('SEOProperties', None) is not None 
  • quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests/config.py

    r1826 r1849  
    1414                    'meta_content' : ''} 
    1515                  ] 
     16DEFAULT_METATAGS_ORDER = ['DC.contributors', 'DC.creator', 'DC.date.created', 
     17                          'DC.date.modified','DC.description', 'DC.distribution', 
     18                          'DC.format', 'DC.language', 'DC.publisher', 'DC.rights', 
     19                          'DC.subject', 'DC.type', 'description', 'distribution', 
     20                          'keywords', 'robots'] 
     21DEFAULT_METATAGS_ORDER.sort() 
    1622VIEW_METATAGS = ['DC.creator', 'DC.format', 'DC.date.modified', 'DC.date.created', 'DC.type', 
    1723                   'DC.distribution', 'description', 'keywords', 'robots', 'distribution'] 
    18  
    1924GLOBAL_CUSTOM_METATAGS = {'default_custom_metatags':'metatag1|global_metatag1value\nmetatag4|global_metatag4value'} 
    2025 
     
    3136qSEO_FOLDER  = [] 
    3237qSEO_TYPES   = qSEO_CONTENT + qSEO_FOLDER 
     38 
     39SEO_CONTENT = ['File', 'Document', 'News Item'] 
     40CONTENTTYPES_WITH_SEOACTION = ['File', 'Document', 'News Item', 'Folder', 'Event'] 
     41CONTENTTYPES_WITH_SEOACTION.sort() 
  • quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/tests/testInstallation.py

    r1837 r1849  
    143143            "Not added 'SEOProperties' action") 
    144144 
     145class TestReinstallation(TestCase): 
     146 
     147    def afterSetUp(self): 
     148        self.qi = self.portal.portal_quickinstaller 
     149        self.types_tool = getToolByName(self.portal, 'portal_types') 
     150        self.setup_tool = getToolByName(self.portal, 'portal_setup') 
     151        self.pprops_tool = getToolByName(self.portal, 'portal_properties') 
     152        self.seoprops_tool = getToolByName(self.pprops_tool, 'seo_properties', None) 
     153        # Set earlier version profile (2.0.0) for using upgrade steps  
     154        self.setup_tool.setLastVersionForProfile('%s:default' % PROJECT_NAME, '2.0.0') 
     155 
     156    def testChangeDomain(self): 
     157        # Test changed of content type's domain from 'quintagroup.seoptimizer' to 'plone' 
     158        for type in SEO_CONTENT: 
     159            self.types_tool.getTypeInfo(type).i18n_domain = 'quintagroup.seoptimizer' 
     160        self.qi.reinstallProducts([PROJECT_NAME]) 
     161        for type in SEO_CONTENT: 
     162            self.assertEqual(self.types_tool.getTypeInfo(type).i18n_domain, 'plone', 
     163                "Not changed of %s content type's domain to 'plone'" % type) 
     164 
     165    def testCutItemsMetatagsOrderList(self): 
     166        # Test changed format metatags order list from "metaname accessor" to "metaname" 
     167        value, expect_mto = ['name1 accessor1', 'name2 accessor2'], ['name1','name2'] 
     168        self.seoprops_tool.manage_changeProperties(metatags_order=value) 
     169        self.qi.reinstallProducts([PROJECT_NAME]) 
     170        mto = list(self.seoprops_tool.getProperty('metatags_order')) 
     171        mto.sort() 
     172        self.assertEqual(mto, expect_mto, 
     173                    "Not changed format metatags order list from \"metaname accessor\" to"\ 
     174                    " \"metaname\". %s != %s" %(mto, expect_mto)) 
     175 
     176    def testAddMetatagsOrderList(self): 
     177        # Test added metatags order list if it was not there before 
     178        self.seoprops_tool.manage_delProperties(['metatags_order']) 
     179        self.qi.reinstallProducts([PROJECT_NAME]) 
     180        mto = list(self.seoprops_tool.getProperty('metatags_order')) 
     181        mto.sort() 
     182        self.assertEqual(mto, DEFAULT_METATAGS_ORDER, 
     183                    "Not added metatags order list with default values."\ 
     184                    "%s != %s" %(mto, DEFAULT_METATAGS_ORDER)) 
     185 
     186    def testMigrationActions(self): 
     187        # Test migrated actions from portal_types action to seoproperties tool 
     188        self.seoprops_tool.content_types_with_seoproperties = () 
     189 
     190        # Add seoaction to content type for testing 
     191        for type in CONTENTTYPES_WITH_SEOACTION: 
     192            self.types_tool.getTypeInfo(type).addAction(id='seo_properties', 
     193                                                   name='SEO Properties', 
     194                                                   action=None, 
     195                                                   condition=None, 
     196                                                   permission=(u'Modify portal content',), 
     197                                                   category='object', 
     198                                                   visible=True, 
     199                                                   icon_expr=None, 
     200                                                   link_target=None, 
     201                                                  ) 
     202            # Check presence seoaction in content type 
     203            seoaction = [act.id for act in self.types_tool.getTypeInfo(type).listActions() 
     204                                          if act.id == 'seo_properties'] 
     205            self.assertEqual(bool(seoaction), True, 
     206                    "Not added seoaction to content type %s for testing" % type) 
     207 
     208        self.qi.reinstallProducts([PROJECT_NAME]) 
     209 
     210        # Check presence seoaction in content type 
     211        for type in CONTENTTYPES_WITH_SEOACTION: 
     212            seoaction = [act.id for act in self.types_tool.getTypeInfo(type).listActions() 
     213                                          if act.id == 'seo_properties'] 
     214            self.assertEqual(bool(seoaction), False, 
     215                "Not removed seoaction in content type %s" % type) 
     216 
     217        # Check added content type names in seo properties tool if content types have seoaction 
     218        ctws = list(self.seoprops_tool.content_types_with_seoproperties) 
     219        ctws.sort() 
     220        self.assertEqual(ctws, CONTENTTYPES_WITH_SEOACTION, 
     221            "Not added content type names in seo properties tool if content types have seoaction."\ 
     222            " %s != %s" %(ctws, CONTENTTYPES_WITH_SEOACTION)) 
     223 
    145224 
    146225def test_suite(): 
     
    150229    suite.addTest(makeSuite(TestInstallation)) 
    151230    suite.addTest(makeSuite(TestUninstallation)) 
     231    suite.addTest(makeSuite(TestReinstallation)) 
    152232    return suite 
Note: See TracChangeset for help on using the changeset viewer.