示例#1
0
def create_conf_from_url(service_url):
    temp_file = NamedTemporaryFile()
    params = [
        '--capabilities', service_url, '--output', temp_file.name, '--force'
    ]
    config_command(params)

    conf_dict = None
    try:
        conf_dict = yaml.load(temp_file)
    except yaml.YAMLError as exc:
        logger.error(exc)
    return conf_dict
    def test_stdout_output(self):
        with capture(bytes=True) as (stdout, stderr):
            assert config_command([
                'mapproxy-conf', '--capabilities',
                filename('util-conf-wms-111-cap.xml')
            ]) == 0

        assert stdout.getvalue().startswith(b'# MapProxy configuration')
示例#3
0
    def test_stdout_output(self):
        with capture(bytes=True) as (stdout, stderr):
            assert (config_command([
                "mapproxy-conf",
                "--capabilities",
                filename("util-conf-wms-111-cap.xml"),
            ]) == 0)

        assert stdout.getvalue().startswith(b"# MapProxy configuration")
    def test_test_cap_output_no_base(self):
        with capture(bytes=True) as (stdout, stderr):
            assert config_command(
                       ['mapproxy-conf',
                        '--capabilities', filename('util-conf-wms-111-cap.xml'),
                        '--output', self.tmp_filename('mapproxy.yaml'), ]) == 0

        with open(self.tmp_filename('mapproxy.yaml'), 'rb') as f:
            conf = yaml.load(f)

            assert 'grids' not in conf
            eq_(conf['sources'], {
                'osm_roads_wms': {
                    'supported_srs': [
                        'CRS:84', 'EPSG:25831', 'EPSG:25832', 'EPSG:25833', 'EPSG:31466', 'EPSG:31467',
                        'EPSG:31468', 'EPSG:3857', 'EPSG:4258', 'EPSG:4326', 'EPSG:900913'],
                    'req': {
                        'layers': 'osm_roads', 'url': 'http://osm.omniscale.net/proxy/service?', 'transparent': True},
                    'type': 'wms',
                    'coverage': {'srs': 'EPSG:4326', 'bbox': [-180.0, -85.0511287798, 180.0, 85.0511287798]}
                },
                'osm_wms': {
                    'supported_srs': [
                        'CRS:84', 'EPSG:25831', 'EPSG:25832', 'EPSG:25833', 'EPSG:31466', 'EPSG:31467', 'EPSG:31468',
                        'EPSG:3857', 'EPSG:4258', 'EPSG:4326', 'EPSG:900913'],
                    'req': {'layers': 'osm', 'url': 'http://osm.omniscale.net/proxy/service?', 'transparent': True},
                    'type': 'wms',
                    'coverage': {
                        'srs': 'EPSG:4326',
                        'bbox': [-180.0, -85.0511287798, 180.0, 85.0511287798],
                    },
                },
            })

            eq_(conf['layers'], [{
                'title': 'Omniscale OpenStreetMap WMS',
                'layers': [
                    {
                        'name': 'osm',
                        'title': 'OpenStreetMap (complete map)',
                        'sources': ['osm_wms'],
                    },
                    {
                        'name': 'osm_roads',
                        'title': 'OpenStreetMap (streets only)',
                        'sources': ['osm_roads_wms'],
                     },
                ]
            }])
            eq_(len(conf['layers'][0]['layers']), 2)
    def test_test_cap_output(self):
        with capture(bytes=True) as (stdout, stderr):
            assert config_command([
                'mapproxy-conf',
                '--capabilities',
                filename('util-conf-wms-111-cap.xml'),
                '--output',
                self.tmp_filename('mapproxy.yaml'),
                '--base',
                filename('util-conf-base-grids.yaml'),
            ]) == 0

        with open(self.tmp_filename('mapproxy.yaml'), 'rb') as f:
            conf = yaml.load(f)

            assert 'grids' not in conf
            eq_(len(conf['sources']), 2)

            eq_(
                conf['caches'], {
                    'osm_cache': {
                        'grids': ['webmercator', 'geodetic'],
                        'sources': ['osm_wms']
                    },
                    'osm_roads_cache': {
                        'grids': ['webmercator', 'geodetic'],
                        'sources': ['osm_roads_wms']
                    },
                })

            eq_(conf['layers'], [{
                'title':
                'Omniscale OpenStreetMap WMS',
                'layers': [
                    {
                        'name': 'osm',
                        'title': 'OpenStreetMap (complete map)',
                        'sources': ['osm_cache'],
                    },
                    {
                        'name': 'osm_roads',
                        'title': 'OpenStreetMap (streets only)',
                        'sources': ['osm_roads_cache'],
                    },
                ]
            }])
            eq_(len(conf['layers'][0]['layers']), 2)
示例#6
0
    def test_test_cap_output(self):
        with capture(bytes=True) as (stdout, stderr):
            assert (config_command([
                "mapproxy-conf",
                "--capabilities",
                filename("util-conf-wms-111-cap.xml"),
                "--output",
                self.tmp_filename("mapproxy.yaml"),
                "--base",
                filename("util-conf-base-grids.yaml"),
            ]) == 0)

        with open(self.tmp_filename("mapproxy.yaml"), "rb") as f:
            conf = yaml.safe_load(f)

            assert "grids" not in conf
            assert len(conf["sources"]) == 2

            assert conf["caches"] == {
                "osm_cache": {
                    "grids": ["webmercator", "geodetic"],
                    "sources": ["osm_wms"],
                },
                "osm_roads_cache": {
                    "grids": ["webmercator", "geodetic"],
                    "sources": ["osm_roads_wms"],
                },
            }

            assert conf["layers"] == [{
                "title":
                "Omniscale OpenStreetMap WMS",
                "layers": [
                    {
                        "name": "osm",
                        "title": "OpenStreetMap (complete map)",
                        "sources": ["osm_cache"],
                    },
                    {
                        "name": "osm_roads",
                        "title": "OpenStreetMap (streets only)",
                        "sources": ["osm_roads_cache"],
                    },
                ],
            }]
            assert len(conf["layers"][0]["layers"]) == 2
示例#7
0
    def test_test_cap_output(self):
        with capture() as (stdout, stderr):
            assert config_command(['mapproxy-conf',
                '--capabilities', filename('util-conf-wms-111-cap.xml'),
                '--output', self.tmp_filename('mapproxy.yaml'),
                '--base', filename('util-conf-base-grids.yaml'),
                ]) == 0


        with open(self.tmp_filename('mapproxy.yaml')) as f:
            conf = yaml.load(f)

            assert 'grids' not in conf
            eq_(len(conf['sources']), 2)

            eq_(conf['caches'], {
                'osm_cache': {
                    'grids': ['webmercator', 'geodetic'],
                    'sources': ['osm_wms']
                },
                'osm_roads_cache': {
                    'grids': ['webmercator', 'geodetic'],
                    'sources': ['osm_roads_wms']
                },
            })


            eq_(conf['layers'], [{
                'title': 'Omniscale OpenStreetMap WMS',
                'layers': [
                    {
                        'name': 'osm',
                        'title': 'OpenStreetMap (complete map)',
                        'sources': ['osm_cache'],
                    },
                    {
                        'name': 'osm_roads',
                        'title': 'OpenStreetMap (streets only)',
                        'sources': ['osm_roads_cache'],
                    },
                ]
            }])
            eq_(len(conf['layers'][0]['layers']), 2)
    def test_test_cap_output_no_base(self):
        with capture(bytes=True) as (stdout, stderr):
            assert config_command([
                'mapproxy-conf',
                '--capabilities',
                filename('util-conf-wms-111-cap.xml'),
                '--output',
                self.tmp_filename('mapproxy.yaml'),
            ]) == 0

        with open(self.tmp_filename('mapproxy.yaml'), 'rb') as f:
            conf = yaml.load(f)

            assert 'grids' not in conf
            eq_(
                conf['sources'], {
                    'osm_roads_wms': {
                        'supported_srs': [
                            'CRS:84', 'EPSG:25831', 'EPSG:25832', 'EPSG:25833',
                            'EPSG:31466', 'EPSG:31467', 'EPSG:31468',
                            'EPSG:3857', 'EPSG:4258', 'EPSG:4326',
                            'EPSG:900913'
                        ],
                        'req': {
                            'layers': 'osm_roads',
                            'url': 'http://osm.omniscale.net/proxy/service?',
                            'transparent': True
                        },
                        'type':
                        'wms',
                        'coverage': {
                            'srs': 'EPSG:4326',
                            'bbox':
                            [-180.0, -85.0511287798, 180.0, 85.0511287798]
                        }
                    },
                    'osm_wms': {
                        'supported_srs': [
                            'CRS:84', 'EPSG:25831', 'EPSG:25832', 'EPSG:25833',
                            'EPSG:31466', 'EPSG:31467', 'EPSG:31468',
                            'EPSG:3857', 'EPSG:4258', 'EPSG:4326',
                            'EPSG:900913'
                        ],
                        'req': {
                            'layers': 'osm',
                            'url': 'http://osm.omniscale.net/proxy/service?',
                            'transparent': True
                        },
                        'type':
                        'wms',
                        'coverage': {
                            'srs': 'EPSG:4326',
                            'bbox':
                            [-180.0, -85.0511287798, 180.0, 85.0511287798],
                        },
                    },
                })

            eq_(conf['layers'], [{
                'title':
                'Omniscale OpenStreetMap WMS',
                'layers': [
                    {
                        'name': 'osm',
                        'title': 'OpenStreetMap (complete map)',
                        'sources': ['osm_wms'],
                    },
                    {
                        'name': 'osm_roads',
                        'title': 'OpenStreetMap (streets only)',
                        'sources': ['osm_roads_wms'],
                    },
                ]
            }])
            eq_(len(conf['layers'][0]['layers']), 2)
    def test_cmd_no_args(self):
        with capture() as (stdout, stderr):
            assert config_command(['mapproxy-conf']) == 2

        assert '--capabilities required' in stderr.getvalue()
示例#10
0
    def test_stdout_output(self):
        with capture() as (stdout, stderr):
            assert config_command(['mapproxy-conf', '--capabilities', filename('util-conf-wms-111-cap.xml')]) == 0

        assert stdout.getvalue().startswith('# MapProxy configuration')
示例#11
0
    def test_cmd_no_args(self):
        with capture() as (stdout, stderr):
            assert config_command(['mapproxy-conf']) == 2

        assert '--capabilities required' in stderr.getvalue()
示例#12
0
    def test_test_cap_output_no_base(self):
        with capture(bytes=True) as (stdout, stderr):
            assert (config_command([
                "mapproxy-conf",
                "--capabilities",
                filename("util-conf-wms-111-cap.xml"),
                "--output",
                self.tmp_filename("mapproxy.yaml"),
            ]) == 0)

        with open(self.tmp_filename("mapproxy.yaml"), "rb") as f:
            conf = yaml.safe_load(f)

            assert "grids" not in conf
            assert conf["sources"] == {
                "osm_roads_wms": {
                    "supported_srs": [
                        "CRS:84",
                        "EPSG:25831",
                        "EPSG:25832",
                        "EPSG:25833",
                        "EPSG:31466",
                        "EPSG:31467",
                        "EPSG:31468",
                        "EPSG:3857",
                        "EPSG:4258",
                        "EPSG:4326",
                        "EPSG:900913",
                    ],
                    "req": {
                        "layers": "osm_roads",
                        "url": "http://osm.omniscale.net/proxy/service?",
                        "transparent": True,
                    },
                    "type":
                    "wms",
                    "coverage": {
                        "srs": "EPSG:4326",
                        "bbox": [-180.0, -85.0511287798, 180.0, 85.0511287798],
                    },
                },
                "osm_wms": {
                    "supported_srs": [
                        "CRS:84",
                        "EPSG:25831",
                        "EPSG:25832",
                        "EPSG:25833",
                        "EPSG:31466",
                        "EPSG:31467",
                        "EPSG:31468",
                        "EPSG:3857",
                        "EPSG:4258",
                        "EPSG:4326",
                        "EPSG:900913",
                    ],
                    "req": {
                        "layers": "osm",
                        "url": "http://osm.omniscale.net/proxy/service?",
                        "transparent": True,
                    },
                    "type":
                    "wms",
                    "coverage": {
                        "srs": "EPSG:4326",
                        "bbox": [-180.0, -85.0511287798, 180.0, 85.0511287798],
                    },
                },
            }

            assert conf["layers"] == [{
                "title":
                "Omniscale OpenStreetMap WMS",
                "layers": [
                    {
                        "name": "osm",
                        "title": "OpenStreetMap (complete map)",
                        "sources": ["osm_wms"],
                    },
                    {
                        "name": "osm_roads",
                        "title": "OpenStreetMap (streets only)",
                        "sources": ["osm_roads_wms"],
                    },
                ],
            }]
            assert len(conf["layers"][0]["layers"]) == 2