source: TI02-CSML/trunk/services/3rdParty/GeoTypes-0.6.0/tests/OGMultiPoint_Test.py @ 2194

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/services/3rdParty/GeoTypes-0.6.0/tests/OGMultiPoint_Test.py@2194
Revision 2194, 3.2 KB checked in by lawrence, 13 years ago (diff)

Adding various specs and 3rd party code of interest for the CSML
services development.

Line 
1
2################################################################################
3# Copyright (c) QinetiQ Plc 2003
4#
5# Licensed under the LGPL. For full license details see the LICENSE file.
6################################################################################
7
8import unittest
9import os
10import TestConfig
11
12if not os.environ.get('USECOVERAGE') == '1':
13    import _OGMultiPoint
14    from _OGMultiPoint import *
15
16from _OGGeometry import OGGeometry
17from _OGPolygon import OGPolygon, OGpolygonFromSequence
18
19from CollectionClassTestBase import CollectionClassTestBase
20
21class OGMultiPointTest(CollectionClassTestBase):   
22
23    _last_num = 0
24
25    testEqualities = CollectionClassTestBase._testEqualities
26    testContainerMethods = CollectionClassTestBase._testContainerMethods
27
28    def getEnumClass(self):
29        x1 = float(OGMultiPointTest._last_num + 1)
30        y1 = float(OGMultiPointTest._last_num + 2)
31        OGMultiPointTest._last_num = OGMultiPointTest._last_num + 2
32
33        return OGpointFromSequence((x1,y1))
34                               
35    def getCollectionClass(self):
36        return OGMultiPoint()
37   
38    def testConstructor(self):
39        geom = OGMultiPoint(-1) # with SRID
40        assert geom.SRID() == -1
41
42        geom = OGMultiPoint() # No SRID
43        assert geom.SRID() == OGGeometry.default_srid
44        assert len(geom) == 0       
45
46    def testFactoryMethods(self):
47
48        points = []
49        # make a tuple of points.
50        for p in xrange(0,10):
51            points.append(self.getEnumClass())
52
53        geom = OGmultiPointFromOGPoints(*points)
54        assert len(geom) == 10, str(len(geom)) + " != 10 "
55
56       
57        geom1 = OGmultiPointFromSequence(
58                ((133.000000, 134.000000),(135.000000, 136.000000),(137.000000, 138.000000))
59                )
60       
61
62    def testReprs(self):
63        geom = OGmultiPointFromSequence(
64                ((133.000000, 134.000000),(135.000000, 136.000000),(137.000000, 138.000000))
65                )
66
67        assert str(geom) == "GeometryFromText('MULTIPOINT (133.000000 134.000000,135.000000 136.000000,137.000000 138.000000)',128)"
68        assert repr(geom) == "(133.000000 134.000000,135.000000 136.000000,137.000000 138.000000)"
69
70       
71       
72    def testzzz_CoverageAssertion(self):
73            try:
74                coverage.stop()
75            except:
76                return 1
77
78            x = coverage.analysis(_OGMultiPoint)
79            assert x[2]==[], "Coverage is less than 100%"
80
81
82def testSuite():
83    return unittest.makeSuite(OGMultiPointTest,'test')
84
85if __name__ == "__main__":
86    if os.environ.get('USECOVERAGE') == '1':
87        try:
88            import coverage
89            coverage.erase()
90            coverage.start()
91            COVERAGE = 1
92            import _OGMultiPoint
93            from _OGMultiPoint import *
94
95
96        except:
97            print "Error setting up coverage checking"
98            COVERAGE = 0
99    else:
100        COVERAGE = 0
101
102    if os.environ.get('USEPYCHECK') == '1':
103        try:
104            import pychecker.checker
105        except:
106            print "Pychecker not installed on this machine"
107
108    unittest.TextTestRunner().run(testSuite())
109
110    if COVERAGE:
111        coverage.stop()
112        x = coverage.analysis(_OGMultiPoint)
113        print "\n"
114        coverage.report(_OGMultiPoint)
Note: See TracBrowser for help on using the repository browser.