source: products/qPloneGoogleMaps/tags/0.1.0/tests/testField.py @ 1591

Last change on this file since 1591 was 1, checked in by myroslav, 15 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1""" This module contains class that tests MapField and MapWidget """
2
3import os, sys
4if __name__ == '__main__':
5    execfile(os.path.join(sys.path[0], 'framework.py'))
6
7from commonTestingStuff import *
8
9class TestMapField(PloneTestCase.PloneTestCase):
10    """ Class for testing MapField and MapWidget """
11
12    def afterSetUp(self):
13        """ AfterSetUp features """
14        self.loginAsPortalOwner()
15        pt=self.portal.portal_types
16        pt.constructContent('MapFieldTest', self.folder, 'mapfield')
17
18    def testMapField(self):
19        """ Test MapField """
20        f = self.folder.mapfield
21        f.update(location=FIELD_VALUE)
22        r = f.getLocation()
23        self.assertEqual(FIELD_VALUE[0], r[0])
24        self.assertEqual(FIELD_VALUE[1], r[1])
25        self.assertEqual(FIELD_VALUE, r)
26
27    def testMapFieldAccessor(self):
28        """ Test the map field accessor """
29        f = self.folder.mapfield
30        f.update(location=FIELD_VALUE)
31        p = f.Schema()['location']
32        self.assertEqual(p.getAccessor(f)(), FIELD_VALUE)
33
34    def testMapWidget(self):
35        """ Test MapWidget """
36        instance = self.folder.mapfield
37        field = instance.Schema()['location']
38        #print field.widget.getName()
39        form={'location_latitude'  : FIELD_VALUE[0],
40              'location_longitude' : FIELD_VALUE[1],}
41        result = field.widget.process_form(instance, field, form, empty_marker=[])
42        self.assertEqual(result[0], FIELD_VALUE)
43
44def test_suite():
45    from unittest import TestSuite, makeSuite
46    suite = TestSuite()
47    suite.addTest(makeSuite(TestMapField))
48    return suite
49
50if __name__ == '__main__':
51    framework()
Note: See TracBrowser for help on using the repository browser.