Skip to content

Commit d48070c

Browse files
authored
Add some basic clusterObj tests (#5927)
* Add some basic clusterObj tests * Lint fix
1 parent b85122d commit d48070c

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Project: MapServer
2+
# Purpose: xUnit style Python mapscript tests of clusterObj
3+
# Author: Seth Girvin
4+
#
5+
# ===========================================================================
6+
# Copyright (c) 2019, Seth Girvin
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a
9+
# copy of this software and associated documentation files (the "Software"),
10+
# to deal in the Software without restriction, including without limitation
11+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
12+
# and/or sell copies of the Software, and to permit persons to whom the
13+
# Software is furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included
16+
# in all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24+
# DEALINGS IN THE SOFTWARE.
25+
# ===========================================================================
26+
27+
import unittest
28+
import mapscript
29+
30+
31+
class ClusterObjTestCase(unittest.TestCase):
32+
33+
def testClusterObjUpdateFromString(self):
34+
"""a cluster can be updated from a string"""
35+
c = mapscript.clusterObj()
36+
c.updateFromString("CLUSTER \n MAXDISTANCE 5 \n REGION \n 'rectangle' END")
37+
38+
assert c.maxdistance == 5
39+
assert c.region == 'rectangle'
40+
41+
s = c.convertToString()
42+
assert s == 'CLUSTER\n MAXDISTANCE 5\n REGION "rectangle"\nEND # CLUSTER\n'
43+
44+
def testClusterObjGetSetFilter(self):
45+
"""a cluster filter can be set and read"""
46+
c = mapscript.clusterObj()
47+
filter = '[attr1] > 5'
48+
c.setFilter(filter)
49+
assert '"{}"'.format(filter) == c.getFilterString()
50+
51+
def testClusterObjGetSetGroup(self):
52+
"""a cluster filter can be set and read"""
53+
c = mapscript.clusterObj()
54+
exp = '100' # TODO not sure what would be a relevant expression here
55+
c.setGroup(exp)
56+
assert '"{}"'.format(exp) == c.getGroupString()
57+
58+
59+
if __name__ == '__main__':
60+
unittest.main()

0 commit comments

Comments
 (0)