def test_no_fetch_missing_tiles(self): self.args += ['--grid', 'GLOBAL_MERCATOR', '--dest', self.dest, '--levels', '0', '--source', 'tms_cache'] with capture_stderr(): export_command(self.args) eq_(os.listdir(self.dest), ['tile_locks'])
def test_config_not_found(self): self.args = ['command_dummy', '-f', 'foo.bar'] with capture_stderr() as err: try: export_command(self.args) except SystemExit, ex: assert ex.code != 0 else:
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'])
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:")
def test_force(self): self.args += ['--grid', 'GLOBAL_MERCATOR', '--dest', self.dest, '--levels', '0', '--source', 'tms_cache'] with capture_stderr(): export_command(self.args) with capture_stderr(): assert_raises(SystemExit, export_command, self.args) with capture_stderr(): export_command(self.args + ['--force'])
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_stderr(): 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_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_stderr(): 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_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_stderr(): 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_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'])
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_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"]
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()
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_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_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_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_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_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"])