[1] | 1 | |
---|
| 2 | """ This module contains class that tests products' adapters """ |
---|
| 3 | |
---|
| 4 | import os, sys |
---|
| 5 | if __name__ == '__main__': |
---|
| 6 | execfile(os.path.join(sys.path[0], 'framework.py')) |
---|
| 7 | |
---|
| 8 | from commonTestingStuff import * |
---|
| 9 | |
---|
| 10 | class TestForInterfaces(PloneTestCase.PloneTestCase): |
---|
| 11 | """ Class for testing adapters' and browsers' for interfaces """ |
---|
| 12 | |
---|
| 13 | def testAdapterInterface(self): |
---|
| 14 | """ Test adapters' for intefaces """ |
---|
| 15 | verifyClass(IPoint, Point) |
---|
| 16 | verifyClass(IGEOMap, GEOMap) |
---|
| 17 | |
---|
| 18 | def testBrowserInterface(self): |
---|
| 19 | """ Test browsers' for intefaces """ |
---|
| 20 | verifyClass(IPointView, PointView) |
---|
| 21 | verifyClass(IGEOMapView, GEOMapView) |
---|
| 22 | |
---|
| 23 | class TestGEOLocatedAdapter(PloneTestCase.PloneTestCase): |
---|
| 24 | """ Class for testing GEOLocated adapter """ |
---|
| 25 | |
---|
| 26 | def afterSetUp(self): |
---|
| 27 | """ AfterSetUp features """ |
---|
| 28 | self.folder.invokeFactory('Document', 'test_page') |
---|
| 29 | self.page = self.folder.test_page |
---|
| 30 | self.adapter = IPoint(self.page) |
---|
| 31 | self.adapter.coordinates = (LONGITUDE, LATITUDE, ALTITUDE) |
---|
| 32 | |
---|
| 33 | def testImplementation(self): |
---|
| 34 | """ Test adapter implementation """ |
---|
| 35 | IPoint.implementedBy(Point) |
---|
| 36 | |
---|
| 37 | def testGetters(self): |
---|
| 38 | """ Test adapters' getters """ |
---|
| 39 | self.failUnlessEqual(self.adapter.coordinates[0], LONGITUDE) |
---|
| 40 | self.failUnlessEqual(self.adapter.coordinates[1], LATITUDE) |
---|
| 41 | self.failUnlessEqual(self.adapter.coordinates[2], ALTITUDE) |
---|
| 42 | |
---|
| 43 | class TestGEOMapAdapter(PloneTestCase.PloneTestCase): |
---|
| 44 | """ Class for testing GEOMap adapter """ |
---|
| 45 | |
---|
| 46 | def afterSetUp(self): |
---|
| 47 | """ AfterSetUp features """ |
---|
| 48 | self.folder.invokeFactory('Document', 'test_page') |
---|
| 49 | self.page = self.folder.test_page |
---|
| 50 | self.adapter = IGEOMap(self.page) |
---|
| 51 | self.adapter.geomap['mapcenter'] = MAP_CENTER |
---|
| 52 | self.adapter.geomap['mapzoom'] = MAP_ZOOM |
---|
| 53 | self.adapter.geomap['maptype'] = MAP_TYPE |
---|
| 54 | |
---|
| 55 | def testImplementation(self): |
---|
| 56 | """ Test adapter implementation """ |
---|
| 57 | IGEOMap.implementedBy(GEOMap) |
---|
| 58 | |
---|
| 59 | def testGetters(self): |
---|
| 60 | """ Test adapters' getters """ |
---|
| 61 | self.failUnlessEqual(self.adapter.getMapCenter(), MAP_CENTER) |
---|
| 62 | self.failUnlessEqual(self.adapter.getMapZoom(), MAP_ZOOM) |
---|
| 63 | self.failUnlessEqual(self.adapter.getMapType(), MAP_TYPE) |
---|
| 64 | |
---|
| 65 | def testSetMapMethod(self): |
---|
| 66 | """ Test setMap adapters' method """ |
---|
| 67 | IGEOMap(self.page).setMap(MAP_CENTER, MAP_ZOOM, MAP_TYPE) |
---|
| 68 | self.failUnlessEqual(self.adapter.geomap['mapcenter'], MAP_CENTER) |
---|
| 69 | self.failUnlessEqual(self.adapter.geomap['mapzoom'], MAP_ZOOM) |
---|
| 70 | self.failUnlessEqual(self.adapter.geomap['maptype'], MAP_TYPE) |
---|
| 71 | |
---|
| 72 | def test_suite(): |
---|
| 73 | from unittest import TestSuite, makeSuite |
---|
| 74 | suite = TestSuite() |
---|
| 75 | suite.addTest(makeSuite(TestForInterfaces)) |
---|
| 76 | suite.addTest(makeSuite(TestGEOLocatedAdapter)) |
---|
| 77 | suite.addTest(makeSuite(TestGEOMapAdapter)) |
---|
| 78 | return suite |
---|
| 79 | |
---|
| 80 | if __name__ == '__main__': |
---|
| 81 | framework() |
---|