Loading django/contrib/gis/maps/google/gmap.py +2 −1 Original line number Diff line number Diff line Loading @@ -134,7 +134,8 @@ class GoogleMap(object): @property def scripts(self): "Returns all <script></script> tags required with Google Maps JavaScript." return format_html('%s\n <script type="text/javascript">\n//<![CDATA[\n%s//]]>\n </script>', self.api_script, mark_safe(self.js)) return format_html('{0}\n <script type="text/javascript">\n//<![CDATA[\n{1}//]]>\n </script>', self.api_script, mark_safe(self.js)) @property def style(self): Loading django/contrib/gis/tests/geoadmin/tests.py +19 −2 Original line number Diff line number Diff line Loading @@ -2,9 +2,10 @@ from __future__ import absolute_import from unittest import skipUnless from django.test import TestCase from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.tests.utils import HAS_SPATIAL_DB from django.test import TestCase from django.test.utils import override_settings if HAS_GEOS and HAS_SPATIAL_DB: from django.contrib.gis import admin Loading @@ -12,6 +13,8 @@ if HAS_GEOS and HAS_SPATIAL_DB: from .models import City GOOGLE_MAPS_API_KEY = 'XXXX' @skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.") class GeoAdminTest(TestCase): Loading Loading @@ -39,7 +42,9 @@ class GeoAdminTest(TestCase): result) def test_olwidget_has_changed(self): """ Check that changes are accurately noticed by OpenLayersWidget. """ """ Check that changes are accurately noticed by OpenLayersWidget. """ geoadmin = admin.site._registry[City] form = geoadmin.get_changelist_form(None)() has_changed = form.fields['point']._has_changed Loading @@ -55,3 +60,15 @@ class GeoAdminTest(TestCase): self.assertFalse(has_changed(initial, data_same)) self.assertFalse(has_changed(initial, data_almost_same)) self.assertTrue(has_changed(initial, data_changed)) @override_settings(GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY) def test_google_map_scripts(self): """ Testing GoogleMap.scripts() output. See #20773. """ from django.contrib.gis.maps.google.gmap import GoogleMap google_map = GoogleMap() scripts = google_map.scripts self.assertIn(GOOGLE_MAPS_API_KEY, scripts) self.assertIn("new GMap2", scripts) Loading
django/contrib/gis/maps/google/gmap.py +2 −1 Original line number Diff line number Diff line Loading @@ -134,7 +134,8 @@ class GoogleMap(object): @property def scripts(self): "Returns all <script></script> tags required with Google Maps JavaScript." return format_html('%s\n <script type="text/javascript">\n//<![CDATA[\n%s//]]>\n </script>', self.api_script, mark_safe(self.js)) return format_html('{0}\n <script type="text/javascript">\n//<![CDATA[\n{1}//]]>\n </script>', self.api_script, mark_safe(self.js)) @property def style(self): Loading
django/contrib/gis/tests/geoadmin/tests.py +19 −2 Original line number Diff line number Diff line Loading @@ -2,9 +2,10 @@ from __future__ import absolute_import from unittest import skipUnless from django.test import TestCase from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.tests.utils import HAS_SPATIAL_DB from django.test import TestCase from django.test.utils import override_settings if HAS_GEOS and HAS_SPATIAL_DB: from django.contrib.gis import admin Loading @@ -12,6 +13,8 @@ if HAS_GEOS and HAS_SPATIAL_DB: from .models import City GOOGLE_MAPS_API_KEY = 'XXXX' @skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.") class GeoAdminTest(TestCase): Loading Loading @@ -39,7 +42,9 @@ class GeoAdminTest(TestCase): result) def test_olwidget_has_changed(self): """ Check that changes are accurately noticed by OpenLayersWidget. """ """ Check that changes are accurately noticed by OpenLayersWidget. """ geoadmin = admin.site._registry[City] form = geoadmin.get_changelist_form(None)() has_changed = form.fields['point']._has_changed Loading @@ -55,3 +60,15 @@ class GeoAdminTest(TestCase): self.assertFalse(has_changed(initial, data_same)) self.assertFalse(has_changed(initial, data_almost_same)) self.assertTrue(has_changed(initial, data_changed)) @override_settings(GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY) def test_google_map_scripts(self): """ Testing GoogleMap.scripts() output. See #20773. """ from django.contrib.gis.maps.google.gmap import GoogleMap google_map = GoogleMap() scripts = google_map.scripts self.assertIn(GOOGLE_MAPS_API_KEY, scripts) self.assertIn("new GMap2", scripts)