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 |
from Thuban.Model.layer import Layer |
23 |
|
24 |
|
25 |
class TestClassification(unittest.TestCase): |
26 |
|
27 |
def test_classification(self): |
28 |
"""Test Classification""" |
29 |
|
30 |
layer = Layer("asdf", "../Data/iceland/political.shp") |
31 |
|
32 |
# |
33 |
# init with no params |
34 |
# |
35 |
c = Classification(layer) |
36 |
self.assertEqual(c.field, None) |
37 |
self.assertNotEqual(c.DefaultData, None) |
38 |
|
39 |
# |
40 |
# SetField |
41 |
# |
42 |
c = Classification(layer) |
43 |
c.SetField("Test") |
44 |
self.assertEqual(c.field, "Test") |
45 |
c.SetField(None) |
46 |
self.assertEqual(c.field, None) |
47 |
|
48 |
# |
49 |
# init with field |
50 |
# |
51 |
c = Classification(layer, "Test") |
52 |
self.assertEqual(c.field, "Test") |
53 |
|
54 |
# |
55 |
# GetProperties |
56 |
# |
57 |
|
58 |
# self.assertEqual(c0.GetProperties(-10), "1") |
59 |
# self.assertEqual(c0.GetProperties(-11), default0) |
60 |
# self.assertEqual(c0.GetProperties(0), "2") # min <= x < max |
61 |
# self.assertEqual(c0.GetProperties(10), default0) |
62 |
# self.assertEqual(c0.GetProperties(11), default0) |
63 |
|
64 |
# self.assertEqual(c1.GetProperties(0), "1") |
65 |
# self.assertEqual(c1.GetProperties("0"), "2") |
66 |
# self.assertEqual(c1.GetProperties(-1), default1) |
67 |
# self.assertEqual(c1.GetProperties(1), default1) |
68 |
# self.assertRaises(TypeError, c1.GetProperties, {'monty':'python'}) |
69 |
|
70 |
# # |
71 |
# # toggle field |
72 |
# # |
73 |
|
74 |
# c0.SetField(None) |
75 |
# self.assertEqual(c0.GetProperties(10), default0) |
76 |
# self.assertEqual(c0.GetProperties(11), default0) |
77 |
|
78 |
# c1.SetField(None) |
79 |
# self.assertEqual(c1.GetProperties(0), default1) |
80 |
# self.assertEqual(c1.GetProperties("0"), default1) |
81 |
|
82 |
# c0.SetField("c0") |
83 |
# self.assertEqual(c0.GetProperties(10), default0) |
84 |
# self.assertEqual(c0.GetProperties(11), default0) |
85 |
|
86 |
# c1.SetField("c1") |
87 |
# self.assertEqual(c1.GetProperties(0), "1") |
88 |
# self.assertEqual(c1.GetProperties("0"), "2") |
89 |
|
90 |
if __name__ == "__main__": |
91 |
unittest.main() |