Coverage for gws-app/gws/lib/crs/_test.py: 100%
34 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
1"""Tests for the crs module."""
3import gws
4import gws.test.util as u
5import gws.lib.crs as crs
8def test_get_no_name():
9 assert not crs.get('')
12def test_get():
13 assert str(crs.get('EPSG:3857')) == '<crs:3857>'
16def test_parse():
17 assert crs.parse('EPSG:3857') == ('epsg', crs.get('3857'))
20def test_parse_srid():
21 assert crs.parse('3857') == ('srid', crs.get('3857'))
24def test_parse_no_format():
25 assert crs.parse('11wrongFormat') == ('', None)
28def test_require():
29 assert crs.require('3857') == crs.get('3857')
32def test_require_exception():
33 with u.raises(Exception):
34 crs.require('FOOBAR')
37def test_best_match():
38 lst = [crs.WEBMERCATOR, crs.WGS84]
39 assert crs.best_match(crs.WGS84, lst) == crs.get('4326')
42def test_best_match_not__list():
43 lst = [crs.WEBMERCATOR]
44 assert crs.best_match(crs.WGS84, lst) == crs.get('3857')
47def test_axis_for_format():
48 assert crs.WGS84.axis_for_format('EPSG') == 'yx'
51def test_transform_extent():
52 assert crs.WGS84.transform_extent(ext=(0.0, 1.0, 1.0, 0.0),
53 crs_to=crs.WEBMERCATOR) == (0.0, 0.0, 111319.49079327357, 111325.1428663851)
56def test_transformer():
57 assert str(crs.WGS84.transformer(crs.WEBMERCATOR)) == (
58 '<bound method Transformer.transform of <Concatenated Operation Transformer: '
59 'pipeline>\n'
60 'Description: axis order change (2D) + Popular Visualisation Pseudo-Mercator\n'
61 'Area of Use:\n'
62 '- name: World\n'
63 '- bounds: (-180.0, -90.0, 180.0, 90.0)>')
66def test_to_string():
67 assert crs.WEBMERCATOR.to_string() == 'EPSG:3857'
70def test_to_geojson():
71 assert crs.WEBMERCATOR.to_geojson() == {'properties': {'name': 'urn:ogc:def:crs:EPSG::3857'}, 'type': 'name'}