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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1356 by jonathan, Wed Jul 2 09:37:59 2003 UTC revision 1898 by bh, Fri Oct 31 14:38:09 2003 UTC
# Line 35  from Thuban.Model.range import Range Line 35  from Thuban.Model.range import Range
35  import copy  import copy
36    
37    
38  class TestClassification(unittest.TestCase):  class TestClassGroupProperties(unittest.TestCase):
39    
40      def test_ClassGroupProperties(self):      def test(self):
41          """Test ClassGroupProperties"""          """Test ClassGroupProperties"""
42    
43          props = ClassGroupProperties()          props = ClassGroupProperties()
# Line 64  class TestClassification(unittest.TestCa Line 64  class TestClassification(unittest.TestCa
64          self.assertNotEqual(newProps1, props)          self.assertNotEqual(newProps1, props)
65          self.assertEqual(newProps1, newProps2)          self.assertEqual(newProps1, newProps2)
66    
67      def test_ClassGroup(self):  
68    class TestClassGroup(unittest.TestCase):
69    
70        def test(self):
71          """Test ClassGroup"""          """Test ClassGroup"""
72    
73          # test constructor with no label          # test constructor with no label
# Line 94  class TestClassification(unittest.TestCa Line 97  class TestClassification(unittest.TestCa
97          # test GetProperties...also a virtual function          # test GetProperties...also a virtual function
98          #self.assertEqual(group.GetProperties(), None)          #self.assertEqual(group.GetProperties(), None)
99    
100      def test_ClassGroupDefault(self):  
101    class TestClassGroupDefault(unittest.TestCase):
102    
103        def test(self):
104          """Test ClassGroupDefault"""          """Test ClassGroupDefault"""
105    
106          defProps = ClassGroupProperties()          defProps = ClassGroupProperties()
# Line 134  class TestClassification(unittest.TestCa Line 140  class TestClassification(unittest.TestCa
140          groupCopy = copy.copy(group)          groupCopy = copy.copy(group)
141          self.assertEqual(group, groupCopy)          self.assertEqual(group, groupCopy)
142    
143      def test_ClassGroupRange(self):  
144    class TestClassGroupRange(unittest.TestCase):
145    
146        def test(self):
147          """Test ClassGroupRange"""          """Test ClassGroupRange"""
148    
149          defProps = ClassGroupProperties()          defProps = ClassGroupProperties()
# Line 150  class TestClassification(unittest.TestCa Line 159  class TestClassification(unittest.TestCa
159          self.assertEqual(group.GetMax(), 1)          self.assertEqual(group.GetMax(), 1)
160          self.assertEqual(group.GetProperties(), defProps)          self.assertEqual(group.GetProperties(), defProps)
161          self.assertEqual(group.GetLabel(), "")          self.assertEqual(group.GetLabel(), "")
162            
163          # test SetMax()          # test SetMax()
164          self.assertRaises(ValueError, group.SetMax, 0)          self.assertRaises(ValueError, group.SetMax, 0)
165          self.assertRaises(ValueError, group.SetMax, -1)          self.assertRaises(ValueError, group.SetMax, -1)
# Line 187  class TestClassification(unittest.TestCa Line 196  class TestClassification(unittest.TestCa
196          groupCopy = copy.copy(group)          groupCopy = copy.copy(group)
197          self.assertEqual(group, groupCopy)          self.assertEqual(group, groupCopy)
198    
199      def test_ClassGroupSingleton(self):  
200    class TestClassGroupSingleton(unittest.TestCase):
201    
202        def test(self):
203          """Test ClassGroupSingleton"""          """Test ClassGroupSingleton"""
204    
205          defProps = ClassGroupProperties()          defProps = ClassGroupProperties()
# Line 232  class TestClassification(unittest.TestCa Line 244  class TestClassification(unittest.TestCa
244          # test copy          # test copy
245          groupCopy = copy.copy(group)          groupCopy = copy.copy(group)
246          self.assertEqual(group, groupCopy)          self.assertEqual(group, groupCopy)
           
247    
248      def test_ClassIterator(self):  
249    class TestClassIterator(unittest.TestCase):
250    
251        def test(self):
252          """Test ClassIterator"""          """Test ClassIterator"""
253    
254          groups = [ClassGroupSingleton(5), ClassGroupSingleton(5),          groups = [ClassGroupSingleton(5), ClassGroupSingleton(5),
# Line 257  class TestClassification(unittest.TestCa Line 271  class TestClassification(unittest.TestCa
271    
272          self.assertEquals(list, [0, 1, 1, 2, 1, 0])          self.assertEquals(list, [0, 1, 1, 2, 1, 0])
273    
274      def test_classification(self):  
275    class TestClassification(unittest.TestCase):
276    
277        def test(self):
278          """Test Classification"""          """Test Classification"""
279    
280          defProps = ClassGroupProperties()          defProps = ClassGroupProperties()
# Line 273  class TestClassification(unittest.TestCa Line 290  class TestClassification(unittest.TestCa
290          # init with no params          # init with no params
291          #          #
292          c = Classification()          c = Classification()
         self.assertEqual(c.GetField(), None)  
         self.assertEqual(c.GetFieldType(), None)  
293          self.assertEqual(c.FindGroup(-1), c.GetDefaultGroup())          self.assertEqual(c.FindGroup(-1), c.GetDefaultGroup())
294    
295          c.SetDefaultLineColor(red)          c.SetDefaultLineColor(red)
# Line 285  class TestClassification(unittest.TestCa Line 300  class TestClassification(unittest.TestCa
300          self.assertEqual(c.GetDefaultFill(), green)          self.assertEqual(c.GetDefaultFill(), green)
301          self.assertEqual(c.GetDefaultLineColor(), red)          self.assertEqual(c.GetDefaultLineColor(), red)
302    
         c.SetFieldInfo("hallo", FIELDTYPE_STRING)  
         self.assertEqual(c.GetField(), "hallo")  
         self.assertEqual(c.GetFieldType(), FIELDTYPE_STRING)  
   
         # should raise an exception because 'hallo' doesn't  
         # exist in the table  
         self.assertRaises(ValueError, c._set_layer, layer)  
           
         c.SetFieldInfo("AREA", None)  
303          layer.SetClassification(c)          layer.SetClassification(c)
         self.assertEqual(c.GetLayer(), layer)  
         self.assertEqual(c.GetField(), "AREA")  
         self.assertEqual(c.GetFieldType(), FIELDTYPE_DOUBLE)  
304    
         c.SetFieldInfo(None, None)  
         self.assertEquals(c.GetFieldType(), None)  
305          self.assertEquals(c.FindGroup(5), c.GetDefaultGroup())          self.assertEquals(c.FindGroup(5), c.GetDefaultGroup())
306    
         c.SetFieldInfo("AREA", None)  
307          s = ClassGroupSingleton(5)          s = ClassGroupSingleton(5)
308          c.AppendGroup(s)          c.AppendGroup(s)
309          self.assertEquals(c.FindGroup(5), s)          self.assertEquals(c.FindGroup(5), s)
# Line 324  class TestClassification(unittest.TestCa Line 324  class TestClassification(unittest.TestCa
324          for i in range(clazz.GetNumGroups()):          for i in range(clazz.GetNumGroups()):
325              self.assertEquals(clazz.GetGroup(i), c.GetGroup(i))              self.assertEquals(clazz.GetGroup(i), c.GetGroup(i))
326    
327            session.Destroy()
328          layer.Destroy()          layer.Destroy()
329    
330    
331  if __name__ == "__main__":  if __name__ == "__main__":
332      support.run_tests()      support.run_tests()

Legend:
Removed from v.1356  
changed lines
  Added in v.1898

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26