source: products/qPloneGoogleMaps/tags/0.1.0/tests/testInstallation.py

Last change on this file was 1, checked in by myroslav, 18 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 7.2 KB
RevLine 
[1]1
2""" This module contains class that tests product's installation  procedure """
3
4#PRODUCTS=('geolocation', 'qPloneGoogleMaps')
5
6import os, sys, string
7if __name__ == '__main__':
8    execfile(os.path.join(sys.path[0], 'framework.py'))
9
10from commonTestingStuff import *
11
12class TestInstallation(PloneTestCase.PloneTestCase):
13    """ Class for testing installation procedure """
14
15    def afterSetUp(self):
16        """ AfterSetUp features """
17        self.properties = getToolByName(self.portal, 'portal_properties')
18        self.qi = getToolByName(self.portal, 'portal_quickinstaller')
19        #self.portal.changeSkin('Plone Default')
20        self.qi.installProduct(PRODUCT)
21        self._refreshSkinData()
22        #self.loginAsPortalOwner()
23
24    def testAddingPropertySheet(self):
25        """ Test adding property sheet to portal_properties tool """
26        self.failUnless(hasattr(self.properties.aq_base, PROPERTY_SHEET))
27
28    def testAddingPropertyField(self):
29        """ Test adding property field to portal_properties.maps_properties sheet """
30        map_sheet = self.properties[PROPERTY_SHEET]
31        self.failUnless(map_sheet.hasProperty(PROPERTY_FIELD) and map_sheet.getProperty(PROPERTY_FIELD)==MAP_API_KEYS)
32
33    def testRemovingPropertySheet(self):
34        """ Test removing property sheet from portal_properties tool """
35        self.qi.uninstallProducts([PRODUCT,])
36        self.assertEqual(self.qi.isProductInstalled(PRODUCT), False,'qPloneGoogleMaps is installed yet')
37        self.failIf(hasattr(self.properties.aq_base, PROPERTY_SHEET),
38                    "There should be no %s sheet in portal_properties tool." % PROPERTY_SHEET)
39
40    def testConfigletInstalling(self):
41        """ Test creating qPloneGoogleMaps configlet """
42        configTool = getToolByName(self.portal, 'portal_controlpanel', None)
43        self.failUnless(PRODUCT in [a.getId() for a in configTool.listActions()], 'Configlet not found')
44
45    def testConfigletUninstall(self):
46        """ Test removing qPloneGoogleMaps configlet """
47        self.qi.uninstallProducts([PRODUCT,])
48        self.assertEqual(self.qi.isProductInstalled(PRODUCT), False, 'qPloneGoogleMaps is installed yet')
49        configTool = getToolByName(self.portal, 'portal_controlpanel', None)
50        self.failIf(PRODUCT in [a.getId() for a in configTool.listActions()], 'Configlet found after uninstallation')
51
52    def testAddingCatalogIndex(self):
53        """ Test adding index to portal_catalog tool """
54        portal_catalog = getToolByName(self.portal, 'portal_catalog')
55        self.failUnless(GEO_INDEX in portal_catalog.indexes(), 'Index not found in portal_catalog')
56
57    def testRemovingCatalogIndex(self):
58        """ Test removing index from portal_catalog tool """
59        self.qi.uninstallProducts([PRODUCT,])
60        self.assertEqual(self.qi.isProductInstalled(PRODUCT), False, 'qPloneGoogleMaps is installed yet')
61        portal_catalog = getToolByName(self.portal, 'portal_catalog')
62        self.failIf(GEO_INDEX in portal_catalog.indexes(), 'Index should not be in in portal_catalog')
63
64    def testAddingCatalogColumn(self):
65        """ Test adding column to portal_catalog tool """
66        portal_catalog = getToolByName(self.portal, 'portal_catalog')
67        self.failUnless(GEO_INDEX in portal_catalog.schema(), 'Column not found in portal_catalog')
68
69    def testRemovingCatalogColumn(self):
70        """ Test removing column from portal_catalog tool """
71        self.qi.uninstallProducts([PRODUCT,])
72        self.assertEqual(self.qi.isProductInstalled(PRODUCT), False, 'qPloneGoogleMaps is installed yet')
73        portal_catalog = getToolByName(self.portal, 'portal_catalog')
74        self.failIf(GEO_INDEX in portal_catalog.schema(), 'Column should not be in in portal_catalog')
75
76    def testInstallingContentTypes(self):
77        """ Test installing content types """
78        content_types = getToolByName(self.portal, 'portal_types').listTypeTitles().keys()
79        for obj in NEW_PORTAL_TYPES:
80            self.failUnless(obj in content_types, '%s content type not in portal_types tool' % obj)
81
82    def testAddingToPortalFactory(self):
83        """ Test adding content types to portal_factory tool """
84        factory_types = getToolByName(self.portal, 'portal_factory').getFactoryTypes().keys()
85        for obj in NEW_PORTAL_TYPES:
86            self.failUnless(obj in factory_types,'%s content type not in factory_types tool' % obj)
87
88    def testAddingFolderishMapView(self):
89        """ Test adding map view template to folderish content types """
90        portal_types = getToolByName(self.portal, 'portal_types', None)
91        for tp in ['Folder', 'Large Plone Folder', 'Topic']:
92            views = list(getattr(getattr(portal_types, tp, None), 'view_methods'))
93            self.failUnless(TOPIC_VIEW in views, '%s should have a %s view template' % (tp, TOPIC_VIEW))
94
95    def testRemovingFolderishMapView(self):
96        """ Test removing map view template from folderish content types """
97        self.qi.uninstallProducts([PRODUCT,])
98        self.assertEqual(self.qi.isProductInstalled(PRODUCT), False, 'qPloneGoogleMaps is installed yet')
99        portal_types = getToolByName(self.portal, 'portal_types', None)
100        for tp in ['Folder', 'Large Plone Folder', 'Topic']:
101            views = list(getattr(getattr(portal_types, tp, None), 'view_methods'))
102            self.failIf(TOPIC_VIEW in views, '%s should not have a %s view template' % (tp, TOPIC_VIEW))
103
104    def testAddingPortlets(self):
105        """ Test adding portlets to right slot """
106        right_slots = getattr(self.portal, 'right_slots', None)
107        for slot in MAP_PORTLETS:
108            self.failUnless(slot in right_slots, '%s not found in right slot' % slot)
109
110    def testRemovingPortlets(self):
111        """ Test removing portlets from right slot """
112        self.qi.uninstallProducts([PRODUCT,])
113        self.assertEqual(self.qi.isProductInstalled(PRODUCT), False, 'qPloneGoogleMaps is installed yet')
114        right_slots = getattr(self.portal, 'right_slots', None)
115        for slot in MAP_PORTLETS:
116            self.failIf(slot in right_slots, '%s should not be in right slot' % slot)
117
118    def testLayerInstalling(self):
119        """ Test skins layer installation """
120        skinstool=getToolByName(self.portal, 'portal_skins') 
121        for skin in skinstool.getSkinSelections():
122            path = skinstool.getSkinPath(skin)
123            path = map(string.strip, string.split(path, ','))
124            self.failUnless(PRODUCT in path, 'qPloneGoogleMaps layer not found in %s' % skin)
125
126    def testLayerRemoving(self):
127        """ Test skins layer uninstallation """
128        self.qi.uninstallProducts([PRODUCT,])
129        self.assertEqual(self.qi.isProductInstalled(PRODUCT), False,'qPloneGoogleMaps is installed yet')
130        skinstool=getToolByName(self.portal, 'portal_skins')
131        for skin in skinstool.getSkinSelections():
132            path = skinstool.getSkinPath(skin)
133            path = map(string.strip, string.split(path, ','))
134            self.failIf(PRODUCT in path, 'qPloneGoogleMaps layer found in %s after uninstallation' % skin)
135
136#tests.append(TestInstallation)
137
138def test_suite():
139    from unittest import TestSuite, makeSuite
140    suite = TestSuite()
141    suite.addTest(makeSuite(TestInstallation))
142    return suite
143
144if __name__ == '__main__':
145    framework()
Note: See TracBrowser for help on using the repository browser.