Repository: CartoDB/cartoframes

Issue:
Update basemap URLs
Basemap URL domains have fastly.net (e.g. here: https://github.com/CartoDB/cartoframes/blob/master/cartoframes/layer.py#L63), this should be replaced by basemaps.cartocdn.com in whole code and tests:
* Old: https://cartodb-basemaps-{s}.global.ssl.fastly.net/
* New: https://{s}.basemaps.cartocdn.com/

Other URL parts remain same. Needed for https://github.com/CartoDB/lbs-services/issues/16

Discussion:

Patch:
diff --git a/cartoframes/layer.py b/cartoframes/layer.py
index 6ddaa641..49143e33 100644
--- a/cartoframes/layer.py
+++ b/cartoframes/layer.py
@@ -60,9 +60,7 @@ class BaseMap(AbstractLayer):
 
         self.source = source
         self.labels = labels
-        stem = 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
-        if source == 'voyager':
-            stem += 'rastertiles'
+        stem = 'https://{s}.basemaps.cartocdn.com/rastertiles/'
 
         if self.is_basic():
             if only_labels:


Test patch:
diff --git a/test/test_layer.py b/test/test_layer.py
index e24117b4..c10e2133 100644
--- a/test/test_layer.py
+++ b/test/test_layer.py
@@ -69,32 +69,32 @@ class TestBaseMap(unittest.TestCase):
         # ensure correct BaseMap urls are created
         # See URLs here: https://carto.com/location-data-services/basemaps/
         self.assertEqual(self.dark_map_all.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
                          'dark_all/{z}/{x}/{y}.png')
         self.assertEqual(self.light_map_all.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
                          'light_all/{z}/{x}/{y}.png')
         self.assertEqual(self.voyager_labels_under.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
-                         'rastertiles/voyager_labels_under/{z}/{x}/{y}.png')
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
+                         'voyager_labels_under/{z}/{x}/{y}.png')
         self.assertEqual(self.dark_map_no_labels.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
                          'dark_nolabels/{z}/{x}/{y}.png')
         self.assertEqual(self.light_map_no_labels.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
                          'light_nolabels/{z}/{x}/{y}.png')
         self.assertEqual(self.voyager_map_no_labels.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
-                         'rastertiles/voyager_nolabels/{z}/{x}/{y}.png')
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
+                         'voyager_nolabels/{z}/{x}/{y}.png')
         self.assertEqual(self.light_only_labels.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
                          'light_only_labels/{z}/{x}/{y}.png')
         self.assertEqual(self.dark_only_labels.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
                          'dark_only_labels/{z}/{x}/{y}.png')
         self.assertEqual(self.voyager_only_labels.url,
-                         'https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
-                         'rastertiles/voyager_only_labels/{z}/{x}/{y}.png')
+                         'https://{s}.basemaps.cartocdn.com/rastertiles/'
+                         'voyager_only_labels/{z}/{x}/{y}.png')
 
         # ensure self.is_basic() works as intended
         self.assertTrue(self.light_map_all.is_basic(),
diff --git a/test/test_maps.py b/test/test_maps.py
index 1e3819ce..429feac2 100644
--- a/test/test_maps.py
+++ b/test/test_maps.py
@@ -62,111 +62,110 @@ class TestMaps(unittest.TestCase):
         map_name = get_map_name(self.layers,
                                 has_zoom=False)
         self.assertEqual(
-                map_name,
-                'cartoframes_ver20170406_layers2_time0_baseid1_labels0_zoom0')
+            map_name,
+            'cartoframes_ver20170406_layers2_time0_baseid1_labels0_zoom0')
         self.assertEqual(
-                get_map_name(self.layers, has_zoom=True),
-                'cartoframes_ver20170406_layers2_time0_baseid1_labels0_zoom1')
+            get_map_name(self.layers, has_zoom=True),
+            'cartoframes_ver20170406_layers2_time0_baseid1_labels0_zoom1')
         self.assertEqual(
-                get_map_name(self.layers_w_time, has_zoom=False),
-                'cartoframes_ver20170406_layers3_time1_baseid1_labels1_zoom0')
+            get_map_name(self.layers_w_time, has_zoom=False),
+            'cartoframes_ver20170406_layers3_time1_baseid1_labels1_zoom0')
 
     def test_map_template(self):
         """maps.map_template_dict"""
         map_template = get_map_template(self.layers, has_zoom=False)
-        js = {
-                "placeholders": {
-                    "north": {
-                        "default": 45,
-                        "type": "number"
-                        },
-                    "cartocss_1": {
-                        "default": ("#layer { "
-                                    "marker-fill: red; "
-                                    "marker-width: 5; "
-                                    "marker-allow-overlap: true; "
-                                    "marker-line-color: #000; "
-                                    "}"),
-                        "type": "sql_ident"
-                        },
-                    "cartocss_0": {
-                        "default": ("#layer { "
-                                    "marker-fill: red; "
-                                    "marker-width: 5; "
-                                    "marker-allow-overlap: true; "
-                                    "marker-line-color: #000; }"),
-                        "type": "sql_ident"
-                        },
-                    "west": {
-                        "default": -45,
-                        "type": "number"
-                        },
-                    "east": {
-                        "default": 45,
-                        "type": "number"
-                        },
-                    "sql_0": {
-                        "default": ("SELECT ST_PointFromText('POINT(0 0)', "
-                                    "4326) AS the_geom, 1 AS cartodb_id, "
-                                    "ST_PointFromText('Point(0 0)', 3857) AS "
-                                    "the_geom_webmercator"),
-                        "type": "sql_ident"
-                        },
-                    "sql_1": {
-                        "default": ("SELECT ST_PointFromText('POINT(0 0)', "
-                                    "4326) AS the_geom, 1 AS cartodb_id, "
-                                    "ST_PointFromText('Point(0 0)', 3857) AS "
-                                    "the_geom_webmercator"),
-                        "type": "sql_ident"
-                        },
-                    "south": {
-                        "default": -45,
-                        "type": "number"
+        filledtemplate = {
+            "placeholders": {
+                "north": {
+                    "default": 45,
+                    "type": "number"
+                },
+                "cartocss_1": {
+                    "default": ("#layer { "
+                                "marker-fill: red; "
+                                "marker-width: 5; "
+                                "marker-allow-overlap: true; "
+                                "marker-line-color: #000; "
+                                "}"),
+                    "type": "sql_ident"
+                },
+                "cartocss_0": {
+                    "default": ("#layer { "
+                                "marker-fill: red; "
+                                "marker-width: 5; "
+                                "marker-allow-overlap: true; "
+                                "marker-line-color: #000; }"),
+                    "type": "sql_ident"
+                },
+                "west": {
+                    "default": -45,
+                    "type": "number"
+                },
+                "east": {
+                    "default": 45,
+                    "type": "number"
+                },
+                "sql_0": {
+                    "default": ("SELECT ST_PointFromText('POINT(0 0)', "
+                                "4326) AS the_geom, 1 AS cartodb_id, "
+                                "ST_PointFromText('Point(0 0)', 3857) AS "
+                                "the_geom_webmercator"),
+                    "type": "sql_ident"
+                },
+                "sql_1": {
+                    "default": ("SELECT ST_PointFromText('POINT(0 0)', "
+                                "4326) AS the_geom, 1 AS cartodb_id, "
+                                "ST_PointFromText('Point(0 0)', 3857) AS "
+                                "the_geom_webmercator"),
+                    "type": "sql_ident"
+                },
+                "south": {
+                    "default": -45,
+                    "type": "number"
+                    }
+                },
+            "version": "0.0.1",
+            "name": ("cartoframes_ver20170406_layers2_time0_baseid1_"
+                     "labels0_zoom0"),
+            "layergroup": {
+                "layers": [
+                    {
+                        "type": "http",
+                        "options": {
+                            "urlTemplate": ("https://{s}.basemaps."
+                                            "cartocdn.com/rastertiles"
+                                            "/dark_all/{z}/{x}/{y}."
+                                            "png"),
+                            "subdomains": "abcd"
                         }
                     },
-                "version": "0.0.1",
-                "name": ("cartoframes_ver20170406_layers2_time0_baseid1_"
-                         "labels0_zoom0"),
-                "layergroup": {
-                        "layers": [
-                            {
-                                "type": "http",
-                                "options": {
-                                    "urlTemplate": ("https://cartodb-basemaps-"
-                                                    "{s}.global.ssl.fastly.net"
-                                                    "/dark_all/{z}/{x}/{y}."
-                                                    "png"),
-                                    "subdomains": "abcd"
-                                    }
-                                },
-                            {
-                                "type": "mapnik",
-                                "options": {
-                                    "cartocss": "<%= cartocss_0 %>",
-                                    "sql": "<%= sql_0 %>",
-                                    "cartocss_version": "2.1.1"
-                                    }
-                                },
-                            {
-                                "type": "mapnik",
-                                "options": {
-                                    "cartocss": "<%= cartocss_1 %>",
-                                    "sql": "<%= sql_1 %>",
-                                    "cartocss_version": "2.1.1"
-                                    }
-                                }
-                            ],
-                        "version": "1.0.1"
-                        },
-                "view": {
-                        "bounds": {
-                            "west": "<%= west %>",
-                            "east": "<%= east %>",
-                            "north": "<%= north %>",
-                            "south": "<%= south %>"
-                            }
+                    {
+                        "type": "mapnik",
+                        "options": {
+                            "cartocss": "<%= cartocss_0 %>",
+                            "sql": "<%= sql_0 %>",
+                            "cartocss_version": "2.1.1"
                         }
+                    },
+                    {
+                        "type": "mapnik",
+                        "options": {
+                            "cartocss": "<%= cartocss_1 %>",
+                            "sql": "<%= sql_1 %>",
+                            "cartocss_version": "2.1.1"
+                        }
+                    }],
+                "version": "1.0.1"
+            },
+            "view": {
+                "bounds": {
+                    "west": "<%= west %>",
+                    "east": "<%= east %>",
+                    "north": "<%= north %>",
+                    "south": "<%= south %>"
                 }
+            }
+        }
 
         map_template_dict = json.loads(map_template)
-        self.assertDictEqual(map_template_dict, js)
+        self.assertDictEqual(map_template_dict, filledtemplate)