2
from django.contrib.gis.gdal import Envelope, OGRException
4
class EnvelopeTest(unittest.TestCase):
7
"Testing Envelope initilization."
8
e1 = Envelope((0, 0, 5, 5))
9
e2 = Envelope(0, 0, 5, 5)
10
e3 = Envelope(0, '0', '5', 5) # Thanks to ww for this
11
e4 = Envelope(e1._envelope)
12
self.assertRaises(OGRException, Envelope, (5, 5, 0, 0))
13
self.assertRaises(OGRException, Envelope, 5, 5, 0, 0)
14
self.assertRaises(OGRException, Envelope, (0, 0, 5, 5, 3))
15
self.assertRaises(OGRException, Envelope, ())
16
self.assertRaises(ValueError, Envelope, 0, 'a', 5, 5)
17
self.assertRaises(TypeError, Envelope, u'foo')
19
def test02_properties(self):
20
"Testing Envelope properties."
21
e = Envelope(0, 0, 2, 3)
22
self.assertEqual(0, e.min_x)
23
self.assertEqual(0, e.min_y)
24
self.assertEqual(2, e.max_x)
25
self.assertEqual(3, e.max_y)
26
self.assertEqual((0, 0), e.ll)
27
self.assertEqual((2, 3), e.ur)
28
self.assertEqual((0, 0, 2, 3), e.tuple)
29
self.assertEqual('POLYGON((0.0 0.0,0.0 3.0,2.0 3.0,2.0 0.0,0.0 0.0))', e.wkt)
30
self.assertEqual('(0.0, 0.0, 2.0, 3.0)', str(e))
32
def test03_equivalence(self):
33
"Testing Envelope equivalence."
34
e1 = Envelope(0.523, 0.217, 253.23, 523.69)
35
e2 = Envelope((0.523, 0.217, 253.23, 523.69))
36
self.assertEqual(e1, e2)
37
self.assertEqual((0.523, 0.217, 253.23, 523.69), e1)
40
s = unittest.TestSuite()
41
s.addTest(unittest.makeSuite(EnvelopeTest))
45
unittest.TextTestRunner(verbosity=verbosity).run(suite())