def test_http_error(self):
        self.args = ['command_dummy', '--host', 'http://foo.doesnotexist']
        with capture() as (out,err):
            assert_raises(SystemExit, wms_capabilities_command, self.args)
        assert err.getvalue().startswith("ERROR:")

        self.args[2] = '/no/valid/url'
        with capture() as (out,err):
            assert_raises(SystemExit, wms_capabilities_command, self.args)
        assert err.getvalue().startswith("ERROR:")
Exemple #2
0
    def test_http_error(self):
        self.args = ['command_dummy', '--host', 'http://foo.doesnotexist']
        with capture() as (out, err):
            assert_raises(SystemExit, wms_capabilities_command, self.args)
        assert err.getvalue().startswith("ERROR:")

        self.args[2] = '/no/valid/url'
        with capture() as (out, err):
            assert_raises(SystemExit, wms_capabilities_command, self.args)
        assert err.getvalue().startswith("ERROR:")
Exemple #3
0
    def test_force(self):
        self.args += ['--grid', 'GLOBAL_MERCATOR', '--dest', self.dest,
            '--levels', '0', '--source', 'tms_cache']
        with capture() as (out, err):
            export_command(self.args)

        with capture() as (out, err):
            assert_raises(SystemExit, export_command, self.args)

        with capture() as (out, err):
            export_command(self.args + ['--force'])
Exemple #4
0
    def test_http_error(self):
        self.args = ["command_dummy", "--host", "http://foo.doesnotexist"]
        with capture() as (out, err):
            with pytest.raises(SystemExit):
                wms_capabilities_command(self.args)
        assert err.getvalue().startswith("ERROR:")

        self.args[2] = "/no/valid/url"
        with capture() as (out, err):
            with pytest.raises(SystemExit):
                wms_capabilities_command(self.args)
        assert err.getvalue().startswith("ERROR:")
Exemple #5
0
    def test_force(self):
        self.args += [
            '--grid', 'GLOBAL_MERCATOR', '--dest', self.dest, '--levels', '0',
            '--source', 'tms_cache'
        ]
        with capture() as (out, err):
            export_command(self.args)

        with capture() as (out, err):
            assert_raises(SystemExit, export_command, self.args)

        with capture() as (out, err):
            export_command(self.args + ['--force'])
Exemple #6
0
    def test_no_fetch_missing_tiles(self):
        self.args += ['--grid', 'GLOBAL_MERCATOR', '--dest', self.dest,
            '--levels', '0', '--source', 'tms_cache']
        with capture() as (out, err):
            export_command(self.args)

        eq_(os.listdir(self.dest), ['tile_locks'])
Exemple #7
0
 def test_ignore_case(self):
     self.args.append('-g')
     self.args.append('global_geodetic')
     with capture() as (out, err):
         grids_command(self.args)
     captured_output = out.getvalue()
     assert "GLOBAL_GEODETIC" in captured_output
Exemple #8
0
 def test_display_single_grid(self):
     self.args.append('-g')
     self.args.append('GLOBAL_MERCATOR')
     with capture() as (out, err):
         grids_command(self.args)
     captured_output = out.getvalue()
     assert "GLOBAL_MERCATOR" in captured_output
Exemple #9
0
 def test_service_exception(self):
     self.args = [
         "command_dummy",
         "--host",
         TESTSERVER_URL + "/service?request=GetCapabilities",
     ]
     with open(SERVICE_EXCEPTION_FILE, "rb") as fp:
         capabilities_doc = fp.read()
         with mock_httpd(
                 TESTSERVER_ADDRESS,
             [(
                 {
                     "path":
                     "/service?request=GetCapabilities&version=1.1.1&service=WMS",
                     "method": "GET",
                 },
                 {
                     "status": "200",
                     "body": capabilities_doc
                 },
             )],
         ):
             with capture() as (out, err):
                 with pytest.raises(SystemExit):
                     wms_capabilities_command(self.args)
             error_msg = err.getvalue().rsplit("-" * 80, 1)[1].strip()
             assert "Not a capabilities document" in error_msg
Exemple #10
0
 def test_parse_130capabilities(self):
     self.args = [
         "command_dummy",
         "--host",
         TESTSERVER_URL + "/service?request=GetCapabilities",
         "--version",
         "1.3.0",
     ]
     with open(CAPABILITIES130_FILE, "rb") as fp:
         capabilities_doc = fp.read()
         with mock_httpd(
                 TESTSERVER_ADDRESS,
             [(
                 {
                     "path":
                     "/service?request=GetCapabilities&version=1.3.0&service=WMS",
                     "method": "GET",
                 },
                 {
                     "status": "200",
                     "body": capabilities_doc
                 },
             )],
         ):
             with capture() as (out, err):
                 wms_capabilities_command(self.args)
             lines = out.getvalue().split("\n")
             assert lines[1].startswith(
                 "Capabilities Document Version 1.3.0")
Exemple #11
0
 def test_request_not_parsable(self):
     with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/service?request=GetCapabilities&version=1.1.1&service=WMS', 'method': 'GET'},
                                           {'status': '200', 'body': ''})]):
         with capture() as (out,err):
             assert_raises(SystemExit, wms_capabilities_command, self.args)
         error_msg = err.getvalue().rsplit('-'*80, 1)[1].strip()
         assert error_msg.startswith('Could not parse the document')
Exemple #12
0
    def test_key_error(self):
        self.args = [
            "command_dummy",
            "--host",
            TESTSERVER_URL + "/service?request=GetCapabilities",
        ]
        with open(CAPABILITIES111_FILE, "rb") as fp:
            capabilities_doc = fp.read()
            capabilities_doc = capabilities_doc.replace(b"minx", b"foo")
            with mock_httpd(
                    TESTSERVER_ADDRESS,
                [(
                    {
                        "path":
                        "/service?request=GetCapabilities&version=1.1.1&service=WMS",
                        "method": "GET",
                    },
                    {
                        "status": "200",
                        "body": capabilities_doc
                    },
                )],
            ):
                with capture() as (out, err):
                    with pytest.raises(SystemExit):
                        wms_capabilities_command(self.args)

                assert err.getvalue().startswith(
                    "XML-Element has no such attribute")
Exemple #13
0
 def test_invalid_grid_definition(self):
     self.args += [
         '--grid', 'foo=1', '--dest', self.dest, '--levels', '0',
         '--source', 'tms_cache'
     ]
     with capture() as (out, err):
         assert_raises(SystemExit, export_command, self.args)
         assert 'foo' in err.getvalue()
    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')
Exemple #15
0
    def test_no_fetch_missing_tiles(self):
        self.args += [
            '--grid', 'GLOBAL_MERCATOR', '--dest', self.dest, '--levels', '0',
            '--source', 'tms_cache'
        ]
        with capture() as (out, err):
            export_command(self.args)

        eq_(os.listdir(self.dest), ['tile_locks'])
Exemple #16
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")
Exemple #17
0
 def test_service_exception(self):
     self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service?request=GetCapabilities']
     with open(SERVICE_EXCEPTION_FILE, 'rb') as fp:
         capabilities_doc = fp.read()
         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/service?request=GetCapabilities&version=1.1.1&service=WMS', 'method': 'GET'},
                                               {'status': '200', 'body': capabilities_doc})]):
             with capture() as (out,err):
                 assert_raises(SystemExit, wms_capabilities_command, self.args)
             error_msg = err.getvalue().rsplit('-'*80, 1)[1].strip()
             assert 'Not a capabilities document' in error_msg
Exemple #18
0
 def test_parse_130capabilities(self):
     self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service?request=GetCapabilities', '--version', '1.3.0']
     with open(CAPABILITIES130_FILE, 'rb') as fp:
         capabilities_doc = fp.read()
         with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/service?request=GetCapabilities&version=1.3.0&service=WMS', 'method': 'GET'},
                                               {'status': '200', 'body': capabilities_doc})]):
             with capture() as (out,err):
                 wms_capabilities_command(self.args)
             lines = out.getvalue().split('\n')
             assert lines[1].startswith('Capabilities Document Version 1.3.0')
Exemple #19
0
 def test_config_not_found(self):
     self.args = ['command_dummy', '-f', 'foo.bar']
     with capture() as (out, err):
         try:
             export_command(self.args)
         except SystemExit as ex:
             assert ex.code != 0
         else:
             assert False, 'export command did not exit'
     assert err.getvalue().startswith("ERROR:")
Exemple #20
0
 def test_config_not_found(self):
     self.args = ['command_dummy', '-f', 'foo.bar']
     with capture() as (out, err):
         try:
             export_command(self.args)
         except SystemExit as ex:
             assert ex.code != 0
         else:
             assert False, 'export command did not exit'
     assert err.getvalue().startswith("ERROR:")
Exemple #21
0
    def test_key_error(self):
        self.args = ['command_dummy', '--host', TESTSERVER_URL + '/service?request=GetCapabilities']
        with open(CAPABILITIES111_FILE, 'rb') as fp:
            capabilities_doc = fp.read()
            capabilities_doc = capabilities_doc.replace(b'minx', b'foo')
            with mock_httpd(TESTSERVER_ADDRESS, [({'path': '/service?request=GetCapabilities&version=1.1.1&service=WMS', 'method': 'GET'},
                                                  {'status': '200', 'body': capabilities_doc})]):
                with capture() as (out,err):
                    assert_raises(SystemExit, wms_capabilities_command, self.args)

                assert err.getvalue().startswith('XML-Element has no such attribute')
Exemple #22
0
    def test_list_configured(self):
        self.args.append('-l')
        with capture() as (out, err):
            grids_command(self.args)
        captured_output = out.getvalue()
        for grid in GRID_NAMES:
            assert grid in captured_output

        number_of_lines = sum(1 for line in captured_output.split('\n') if line)

        assert number_of_lines == len(GRID_NAMES)
Exemple #23
0
    def test_force(self):
        self.args += [
            "--grid",
            "GLOBAL_MERCATOR",
            "--dest",
            self.dest,
            "--levels",
            "0",
            "--source",
            "tms_cache",
        ]
        with capture() as (out, err):
            export_command(self.args)

        with capture() as (out, err):
            with pytest.raises(SystemExit):
                export_command(self.args)

        with capture() as (out, err):
            export_command(self.args + ["--force"])
Exemple #24
0
    def test_coverage(self):
        self.args += ['--grid', 'GLOBAL_MERCATOR', '--dest', self.dest,
            '--levels', '0..2', '--source', 'tms_cache', '--fetch-missing-tiles',
            '--coverage', '10,10,20,20', '--srs', 'EPSG:4326']
        with tile_server([(0, 0, 0), (1, 1, 1), (2, 2, 2)]):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, 'tile_locks'))
        assert os.path.exists(os.path.join(self.dest, '0', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '1', '1.png'))
        assert os.path.exists(os.path.join(self.dest, '2', '2', '2.png'))
Exemple #25
0
    def test_fetch_missing_tiles(self):
        self.args += ['--grid', 'GLOBAL_MERCATOR', '--dest', self.dest,
            '--levels', '0,1', '--source', 'tms_cache', '--fetch-missing-tiles']
        with tile_server([(0, 0, 0), (0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 1)]):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, 'tile_locks'))
        assert os.path.exists(os.path.join(self.dest, '0', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '0', '1.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '1', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '1', '1.png'))
Exemple #26
0
    def test_custom_grid(self):
        self.args += ['--grid', 'base=GLOBAL_MERCATOR min_res=100000', '--dest', self.dest,
            '--levels', '1', '--source', 'tms_cache', '--fetch-missing-tiles']
        with tile_server([(0, 3, 2), (1, 3, 2), (2, 3, 2), (3, 3, 2),
                          (0, 2, 2), (1, 2, 2), (2, 2, 2), (3, 2, 2),
                          (0, 1, 2), (1, 1, 2), (2, 1, 2), (3, 1, 2),
                          (0, 0, 2), (1, 0, 2), (2, 0, 2), (3, 0, 2)]):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, 'tile_locks'))
        assert os.path.exists(os.path.join(self.dest, '1', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '3', '3.png'))
Exemple #27
0
    def test_list_configured_all(self):
        self.args.append("-l")
        self.args.append("--all")
        with capture() as (out, err):
            grids_command(self.args)
        captured_output = out.getvalue()
        for grid in GRID_NAMES + UNUSED_GRID_NAMES:
            assert grid in captured_output

        number_of_lines = sum(1 for line in captured_output.split("\n")
                              if line)

        assert number_of_lines == len(UNUSED_GRID_NAMES) + len(GRID_NAMES)
Exemple #28
0
    def test_coverage(self):
        self.args += [
            '--grid', 'GLOBAL_MERCATOR', '--dest', self.dest, '--levels',
            '0..2', '--source', 'tms_cache', '--fetch-missing-tiles',
            '--coverage', '10,10,20,20', '--srs', 'EPSG:4326'
        ]
        with tile_server([(0, 0, 0), (1, 1, 1), (2, 2, 2)]):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, 'tile_locks'))
        assert os.path.exists(os.path.join(self.dest, '0', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '1', '1.png'))
        assert os.path.exists(os.path.join(self.dest, '2', '2', '2.png'))
    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)
Exemple #30
0
    def test_no_fetch_missing_tiles(self):
        self.args += [
            "--grid",
            "GLOBAL_MERCATOR",
            "--dest",
            self.dest,
            "--levels",
            "0",
            "--source",
            "tms_cache",
        ]
        with capture() as (out, err):
            export_command(self.args)

        assert os.listdir(self.dest) == ["tile_locks"]
Exemple #31
0
 def test_invalid_grid_definition(self):
     self.args += [
         "--grid",
         "foo=1",
         "--dest",
         self.dest,
         "--levels",
         "0",
         "--source",
         "tms_cache",
     ]
     with capture() as (out, err):
         with pytest.raises(SystemExit):
             export_command(self.args)
         assert "foo" in err.getvalue()
Exemple #32
0
    def test_fetch_missing_tiles(self):
        self.args += [
            '--grid', 'GLOBAL_MERCATOR', '--dest', self.dest, '--levels',
            '0,1', '--source', 'tms_cache', '--fetch-missing-tiles'
        ]
        with tile_server([(0, 0, 0), (0, 0, 1), (0, 1, 1), (1, 0, 1),
                          (1, 1, 1)]):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, 'tile_locks'))
        assert os.path.exists(os.path.join(self.dest, '0', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '0', '1.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '1', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '1', '1.png'))
    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)
Exemple #34
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
Exemple #35
0
    def test_custom_grid(self):
        self.args += [
            '--grid', 'base=GLOBAL_MERCATOR min_res=100000', '--dest',
            self.dest, '--levels', '1', '--source', 'tms_cache',
            '--fetch-missing-tiles'
        ]
        with tile_server([
            (0, 3, 2), (1, 3, 2), (2, 3, 2), (3, 3, 2), (0, 2, 2), (1, 2, 2),
            (2, 2, 2), (3, 2, 2), (0, 1, 2), (1, 1, 2), (2, 1, 2), (3, 1, 2),
            (0, 0, 2), (1, 0, 2), (2, 0, 2), (3, 0, 2)
        ]):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, 'tile_locks'))
        assert os.path.exists(os.path.join(self.dest, '1', '0', '0.png'))
        assert os.path.exists(os.path.join(self.dest, '1', '3', '3.png'))
Exemple #36
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.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)
Exemple #37
0
 def test_request_not_parsable(self):
     with mock_httpd(
             TESTSERVER_ADDRESS,
         [(
             {
                 "path":
                 "/service?request=GetCapabilities&version=1.1.1&service=WMS",
                 "method": "GET",
             },
             {
                 "status": "200",
                 "body": ""
             },
         )],
     ):
         with capture() as (out, err):
             with pytest.raises(SystemExit):
                 wms_capabilities_command(self.args)
         error_msg = err.getvalue().rsplit("-" * 80, 1)[1].strip()
         assert error_msg.startswith("Could not parse the document")
Exemple #38
0
    def test_fetch_missing_tiles(self):
        self.args += [
            "--grid",
            "GLOBAL_MERCATOR",
            "--dest",
            self.dest,
            "--levels",
            "0,1",
            "--source",
            "tms_cache",
            "--fetch-missing-tiles",
        ]
        with tile_server([(0, 0, 0), (0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 1)]):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, "tile_locks"))
        assert os.path.exists(os.path.join(self.dest, "0", "0", "0.png"))
        assert os.path.exists(os.path.join(self.dest, "1", "0", "0.png"))
        assert os.path.exists(os.path.join(self.dest, "1", "0", "1.png"))
        assert os.path.exists(os.path.join(self.dest, "1", "1", "0.png"))
        assert os.path.exists(os.path.join(self.dest, "1", "1", "1.png"))
Exemple #39
0
    def test_custom_grid(self):
        self.args += [
            "--grid",
            "base=GLOBAL_MERCATOR min_res=100000",
            "--dest",
            self.dest,
            "--levels",
            "1",
            "--source",
            "tms_cache",
            "--fetch-missing-tiles",
        ]
        with tile_server(
            [
                (0, 3, 2),
                (1, 3, 2),
                (2, 3, 2),
                (3, 3, 2),
                (0, 2, 2),
                (1, 2, 2),
                (2, 2, 2),
                (3, 2, 2),
                (0, 1, 2),
                (1, 1, 2),
                (2, 1, 2),
                (3, 1, 2),
                (0, 0, 2),
                (1, 0, 2),
                (2, 0, 2),
                (3, 0, 2),
            ]
        ):
            with capture() as (out, err):
                export_command(self.args)

        assert os.path.exists(os.path.join(self.dest, "tile_locks"))
        assert os.path.exists(os.path.join(self.dest, "1", "0", "0.png"))
        assert os.path.exists(os.path.join(self.dest, "1", "3", "3.png"))
    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')
Exemple #41
0
 def test_config_not_found(self):
     self.args = ['command_dummy', '-f', 'foo.bar']
     with capture() as (_, err):
         assert_raises(SystemExit, grids_command, self.args)
     assert err.getvalue().startswith("ERROR:")
    def test_cmd_no_args(self):
        with capture() as (stdout, stderr):
            assert config_command(['mapproxy-conf']) == 2

        assert '--capabilities required' in stderr.getvalue()
Exemple #43
0
 def test_invalid_grid_definition(self):
     self.args += ['--grid', 'foo=1', '--dest', self.dest,
         '--levels', '0', '--source', 'tms_cache']
     with capture() as (out, err):
         assert_raises(SystemExit, export_command, self.args)
         assert 'foo' in err.getvalue()
Exemple #44
0
 def test_all_grids(self):
     with capture() as (out, err):
         grids_command(self.args)
     captured_output = out.getvalue()
     assert "GLOBAL_MERCATOR" in captured_output
     assert "origin*: 'll'" in captured_output