71 |
proj = Projection(params, "MyName") |
proj = Projection(params, "MyName") |
72 |
self.assertEquals(proj.GetName(), "MyName") |
self.assertEquals(proj.GetName(), "MyName") |
73 |
|
|
74 |
|
def test_get_parameter_without_equals_sign(self): |
75 |
|
"""Test Projection.GetParameter() for a parameter without '=' sign""" |
76 |
|
proj = Projection(["proj=utm", "zone=34", "south", "ellps=clrk66"]) |
77 |
|
# The Projection class pretends that for parameters specified |
78 |
|
# without a value the value is the same as the parameter name. |
79 |
|
self.assertEquals(proj.GetParameter("south"), "south") |
80 |
|
|
81 |
def test_get_projection_units_geo(self): |
def test_get_projection_units_geo(self): |
82 |
"""Test Projection.GetProjectedUnits() for geographic projection""" |
"""Test Projection.GetProjectedUnits() for geographic projection""" |
83 |
proj = Projection(["proj=latlong", "to_meter=0.017453292519943295", |
proj = Projection(["proj=latlong", "to_meter=0.017453292519943295", |
213 |
|
|
214 |
def testRead(self): |
def testRead(self): |
215 |
"""Test read_proj_file""" |
"""Test read_proj_file""" |
|
|
|
216 |
self.doTestRead(sample_projfile_data, sample_projfile) |
self.doTestRead(sample_projfile_data, sample_projfile) |
217 |
self.doTestRead(sample_projfile_data2, sample_projfile2) |
self.doTestRead(sample_projfile_data2, sample_projfile2) |
218 |
|
|
219 |
# |
def test_read_non_existing_file(self): |
220 |
# file doesn't exist |
"""Test read_proj_file with non-existing file""" |
|
# |
|
221 |
self.assertRaises(IOError, |
self.assertRaises(IOError, |
222 |
resource.read_proj_file, self.temp_file_name("nonexistent.proj")) |
resource.read_proj_file, |
223 |
|
self.temp_file_name("nonexistent.proj")) |
224 |
|
|
225 |
# |
def test_read_unreadable_file(self): |
226 |
# file isn't readable |
"""Test read_proj_file with unreadable file |
227 |
# |
|
228 |
|
As currently written this only works on unix-like systems and |
229 |
|
not e.g. on MS Windows. |
230 |
|
""" |
231 |
filename = self.temp_file_name("projfile.proj") |
filename = self.temp_file_name("projfile.proj") |
232 |
file = open(filename, "w") |
file = open(filename, "w") |
233 |
file.close() |
file.close() |
235 |
self.assertRaises(IOError, resource.read_proj_file, filename) |
self.assertRaises(IOError, resource.read_proj_file, filename) |
236 |
os.chmod(filename, 0600) # read/write so we reuse the file |
os.chmod(filename, 0600) # read/write so we reuse the file |
237 |
|
|
238 |
# |
def test_read_empty_file(self): |
239 |
# file has invalid XML (or none at all) |
"""Test read_proj_file with empty file""" |
|
# |
|
240 |
filename = self.temp_file_name("projfile.proj") |
filename = self.temp_file_name("projfile.proj") |
241 |
file = open(filename, "w") |
file = open(filename, "w") |
242 |
file.close() |
file.close() |