def _create_source(self, connection): conn_type = connection["type"] if conn_type == ConnectionTypes.TileJSON: source = ServerSource(url=connection["url"]) elif conn_type == ConnectionTypes.MBTiles: source = MBTilesSource(path=connection["path"]) elif conn_type == ConnectionTypes.Directory: source = DirectorySource(path=connection["path"]) else: raise RuntimeError("Type not set on connection") source.progress_changed.connect(self._source_progress_changed) source.max_progress_changed.connect(self._source_max_progress_changed) source.message_changed.connect(self._source_message_changed) source.tile_limit_reached.connect(self._source_tile_limit_reached) return source
def test_load(self, mock_url_exists, mock_load_tiles_async, mock_tile_json): src = ServerSource("https://localhost") mock_url_exists.assert_called_with("https://localhost") tiles = src.load_tiles(14, [(1, 1)]) self.assertEqual(1, len(tiles))
def test_non_existing_url(self): with self.assertRaises(RuntimeError) as ctx: ServerSource("http://localhost/mytilejson.json") error = "Loading error: Connection refused\n\nURL incorrect?" print ctx.exception self.assertTrue(error in ctx.exception)
def test_non_existing_url(self): with self.assertRaises(RuntimeError) as ctx: ServerSource("http://localhost/mytilejson.json") error = "HTTP HEAD failed: status None" self.assertTrue(error in ctx.exception)