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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/services/3rdParty/GeoTypes-0.6.0/tests/OGMultiLineString_Test.py@2194
Revision 2194, 4.1 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 _OGMultiLineString
14    from _OGMultiLineString import *
15
16from _OGGeometry import OGGeometry
17from _OGPolygon import OGPolygon, OGpolygonFromSequence
18
19from CollectionClassTestBase import CollectionClassTestBase
20
21class OGMultiLineStringTest(CollectionClassTestBase):   
22
23    _last_num = 0
24
25    testEqualities = CollectionClassTestBase._testEqualities
26    testContainerMethods = CollectionClassTestBase._testContainerMethods
27
28    def getEnumClass(self):
29        x1 = float(OGMultiLineStringTest._last_num + 1)
30        y1 = float(OGMultiLineStringTest._last_num + 2)
31        OGMultiLineStringTest._last_num = OGMultiLineStringTest._last_num + 2
32        x2 = float(OGMultiLineStringTest._last_num + 1)
33        y2 = float(OGMultiLineStringTest._last_num + 2)
34        OGMultiLineStringTest._last_num = OGMultiLineStringTest._last_num + 2
35        x3 = float(OGMultiLineStringTest._last_num + 1)
36        y3 = float(OGMultiLineStringTest._last_num + 2)
37        OGMultiLineStringTest._last_num = OGMultiLineStringTest._last_num + 2
38
39        return OGlineStringFromSequence(
40            ((x1,y1),(x2,y2),(x3,y3))
41            )
42                               
43    def getCollectionClass(self):
44        return OGMultiLineString()
45   
46    def testConstructor(self):
47        geom = OGMultiLineString(-1) # with SRID
48        assert geom.SRID() == -1
49
50        geom = OGMultiLineString() # No SRID
51        assert geom.SRID() == OGGeometry.default_srid
52        assert len(geom) == 0       
53
54    def testFactoryMethods(self):
55
56        linestrings = []
57        # make a tuple of points.
58        for p in xrange(0,10):
59            linestrings.append(self.getEnumClass())
60
61        geom = OGmultiLineStringFromOGLineStrings(*linestrings)
62        assert len(geom) == 10, str(len(geom)) + " != 10 "
63
64       
65        geom1 = OGmultiLineStringFromSequence(
66               (((133.000000, 134.000000),(135.000000, 136.000000),(137.000000, 138.000000)),
67               ((139.000000, 140.000000),(141.000000, 142.000000),(143.000000, 144.000000)))
68               )
69       
70
71    def testReprs(self):
72        geom = OGmultiLineStringFromSequence(
73               (((133.000000, 134.000000),(135.000000, 136.000000),(137.000000, 138.000000)),
74               ((139.000000, 140.000000),(141.000000, 142.000000),(143.000000, 144.000000)))
75               )
76           
77        assert str(geom) == "GeometryFromText('MULTILINESTRING ((133.000000 134.000000,135.000000 136.000000,137.000000 138.000000),(139.000000 140.000000,141.000000 142.000000,143.000000 144.000000))',128)"
78        assert repr(geom) == "((133.000000 134.000000,135.000000 136.000000,137.000000 138.000000),(139.000000 140.000000,141.000000 142.000000,143.000000 144.000000))"
79
80       
81       
82    def testzzz_CoverageAssertion(self):
83            try:
84                coverage.stop()
85            except:
86                return 1
87
88            x = coverage.analysis(_OGMultiLineString)
89            assert x[2]==[], "Coverage is less than 100%"
90
91
92def testSuite():
93    return unittest.makeSuite(OGMultiLineStringTest,'test')
94
95if __name__ == "__main__":
96    if os.environ.get('USECOVERAGE') == '1':
97        try:
98            import coverage
99            coverage.erase()
100            coverage.start()
101            COVERAGE = 1
102            import _OGMultiLineString
103            from _OGMultiLineString import *
104
105
106        except:
107            print "Error setting up coverage checking"
108            COVERAGE = 0
109    else:
110        COVERAGE = 0
111
112    if os.environ.get('USEPYCHECK') == '1':
113        try:
114            import pychecker.checker
115        except:
116            print "Pychecker not installed on this machine"
117
118    unittest.TextTestRunner().run(testSuite())
119
120    if COVERAGE:
121        coverage.stop()
122        x = coverage.analysis(_OGMultiLineString)
123        print "\n"
124        coverage.report(_OGMultiLineString)
Note: See TracBrowser for help on using the repository browser.