/[thuban]/branches/WIP-pyshapelib-bramz/test/test_classification.py
ViewVC logotype

Contents of /branches/WIP-pyshapelib-bramz/test/test_classification.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 369 - (show annotations)
Mon Jan 27 11:53:51 2003 UTC (22 years, 1 month ago) by jonathan
Original Path: trunk/thuban/test/test_classification.py
File MIME type: text/x-python
File size: 2763 byte(s)
tests for Classification class

1 # Copyright (c) 2002 by Intevation GmbH
2 # Authors:
3 # Jonathan Coles <[email protected]>
4 #
5 # This program is free software under the GPL (>=v2)
6 # Read the file COPYING coming with Thuban for details.
7
8 """
9 Test the Classification class
10 """
11
12 __version__ = "$Revision$"
13 # $Source$
14 # $Id$
15
16 import unittest
17
18 import support
19 support.initthuban()
20
21 from Thuban.Model.classification import Classification
22
23
24 class TestClassification(unittest.TestCase):
25
26 def test_classification(self):
27 """Test Classification"""
28
29 #
30 # init with no params
31 #
32 c = Classification()
33 self.assertEquals(c.field, None)
34 self.assertEquals(c.NullData, None)
35
36 #
37 # setField
38 #
39 c = Classification()
40 c.setField("Test")
41 self.assertEquals(c.field, "Test")
42 c.setField(None)
43 self.assertEquals(c.field, None)
44
45 #
46 # init with field
47 #
48 c = Classification("Test")
49 self.assertEquals(c.field, "Test")
50 self.assertEquals(c.NullData, None)
51
52 #
53 # addRange
54 #
55 c0 = Classification("c0")
56 self.assertRaises(ValueError, c0.addRange, 0, 0, None)
57 self.assertRaises(ValueError, c0.addRange, 10, 0, None)
58 c0.addRange(-10, 0, "1")
59 c0.addRange(0, 10, "2")
60
61 #
62 # addPoint
63 #
64 c1 = Classification("c1")
65 c1.addPoint(0, "1")
66 c1.addPoint("0", "2")
67 self.assertRaises(TypeError, c1.addPoint, {'monty':'python'}, "3")
68
69 #
70 # getProperties
71 #
72
73 self.assertEqual(c0.getProperties(-10), "1")
74 self.assertEqual(c0.getProperties(-11), None)
75 self.assertEqual(c0.getProperties(0), "2") # min <= x < max
76 self.assertEqual(c0.getProperties(10), None)
77 self.assertEqual(c0.getProperties(11), None)
78
79 self.assertEqual(c1.getProperties(0), "1")
80 self.assertEqual(c1.getProperties("0"), "2")
81 self.assertEqual(c1.getProperties(-1), None)
82 self.assertEqual(c1.getProperties(1), None)
83 self.assertRaises(TypeError, c1.getProperties, {'monty':'python'})
84
85 #
86 # toggle field
87 #
88
89 c0.setField(None)
90 self.assertEqual(c0.getProperties(10), None)
91 self.assertEqual(c0.getProperties(11), None)
92
93 c1.setField(None)
94 self.assertEqual(c1.getProperties(0), None)
95 self.assertEqual(c1.getProperties("0"), None)
96
97 c0.setField("c0")
98 self.assertEqual(c0.getProperties(10), None)
99 self.assertEqual(c0.getProperties(11), None)
100
101 c1.setField("c1")
102 self.assertEqual(c1.getProperties(0), "1")
103 self.assertEqual(c1.getProperties("0"), "2")
104
105 if __name__ == "__main__":
106 unittest.main()

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26