| 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(IGEOLocated, GEOLocated) |
|---|
| 16 | verifyClass(IGEOMap, GEOMap) |
|---|
| 17 | |
|---|
| 18 | def testBrowserInterface(self): |
|---|
| 19 | """ Test browsers' for intefaces """ |
|---|
| 20 | verifyClass(IGEOLocatedView, GEOLocatedView) |
|---|
| 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 = IGEOLocated(self.page) |
|---|
| 31 | self.adapter.geolocation['latitude'] = LATITUDE |
|---|
| 32 | self.adapter.geolocation['longitude'] = LONGITUDE |
|---|
| 33 | |
|---|
| 34 | def testImplementation(self): |
|---|
| 35 | """ Test adapter implementation """ |
|---|
| 36 | IGEOLocated.implementedBy(GEOLocated) |
|---|
| 37 | |
|---|
| 38 | def testGetters(self): |
|---|
| 39 | """ Test adapters' getters """ |
|---|
| 40 | self.failUnlessEqual(self.adapter.getLongitude(), LONGITUDE) |
|---|
| 41 | self.failUnlessEqual(self.adapter.getLatitude(), LATITUDE) |
|---|
| 42 | |
|---|
| 43 | def testSetters(self): |
|---|
| 44 | """ Test adapters' setters """ |
|---|
| 45 | adapter = IGEOLocated(self.page) |
|---|
| 46 | adapter.setLatitude(LATITUDE) |
|---|
| 47 | adapter.setLongitude(LONGITUDE) |
|---|
| 48 | self.failUnlessEqual(self.adapter.geolocation['latitude'], LATITUDE) |
|---|
| 49 | self.failUnlessEqual(self.adapter.geolocation['longitude'], LONGITUDE) |
|---|
| 50 | |
|---|
| 51 | def testSetLocationMethod(self): |
|---|
| 52 | """ Test setLocation adapters' method """ |
|---|
| 53 | IGEOLocated(self.page).setLocation(LATITUDE, LONGITUDE) |
|---|
| 54 | self.failUnlessEqual(self.adapter.geolocation['latitude'], LATITUDE) |
|---|
| 55 | self.failUnlessEqual(self.adapter.geolocation['longitude'], LONGITUDE) |
|---|
| 56 | |
|---|
| 57 | class TestGEOMapAdapter(PloneTestCase.PloneTestCase): |
|---|
| 58 | """ Class for testing GEOMap adapter """ |
|---|
| 59 | |
|---|
| 60 | def afterSetUp(self): |
|---|
| 61 | """ AfterSetUp features """ |
|---|
| 62 | self.folder.invokeFactory('Document', 'test_page') |
|---|
| 63 | self.page = self.folder.test_page |
|---|
| 64 | self.adapter = IGEOMap(self.page) |
|---|
| 65 | self.adapter.geomap['mapcenter'] = MAP_CENTER |
|---|
| 66 | self.adapter.geomap['mapzoom'] = MAP_ZOOM |
|---|
| 67 | self.adapter.geomap['maptype'] = MAP_TYPE |
|---|
| 68 | |
|---|
| 69 | def testImplementation(self): |
|---|
| 70 | """ Test adapter implementation """ |
|---|
| 71 | IGEOMap.implementedBy(GEOMap) |
|---|
| 72 | |
|---|
| 73 | def testGetters(self): |
|---|
| 74 | """ Test adapters' getters """ |
|---|
| 75 | self.failUnlessEqual(self.adapter.getMapCenter(), MAP_CENTER) |
|---|
| 76 | self.failUnlessEqual(self.adapter.getMapZoom(), MAP_ZOOM) |
|---|
| 77 | self.failUnlessEqual(self.adapter.getMapType(), MAP_TYPE) |
|---|
| 78 | |
|---|
| 79 | def testSetMapMethod(self): |
|---|
| 80 | """ Test setMap adapters' method """ |
|---|
| 81 | IGEOMap(self.page).setMap(MAP_CENTER, MAP_ZOOM, MAP_TYPE) |
|---|
| 82 | self.failUnlessEqual(self.adapter.geomap['mapcenter'], MAP_CENTER) |
|---|
| 83 | self.failUnlessEqual(self.adapter.geomap['mapzoom'], MAP_ZOOM) |
|---|
| 84 | self.failUnlessEqual(self.adapter.geomap['maptype'], MAP_TYPE) |
|---|
| 85 | |
|---|
| 86 | def test_suite(): |
|---|
| 87 | from unittest import TestSuite, makeSuite |
|---|
| 88 | suite = TestSuite() |
|---|
| 89 | suite.addTest(makeSuite(TestForInterfaces)) |
|---|
| 90 | suite.addTest(makeSuite(TestGEOLocatedAdapter)) |
|---|
| 91 | suite.addTest(makeSuite(TestGEOMapAdapter)) |
|---|
| 92 | return suite |
|---|
| 93 | |
|---|
| 94 | if __name__ == '__main__': |
|---|
| 95 | framework() |
|---|