2014-02-03 10:46:17 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
from unittest import skipUnless
|
|
|
|
|
|
2014-02-05 20:15:47 +00:00
|
|
|
|
from django.contrib.gis.geos import HAS_GEOS
|
2014-02-03 10:46:17 +00:00
|
|
|
|
from django.test import TestCase
|
2015-02-10 15:07:44 +00:00
|
|
|
|
from django.test.utils import modify_settings, override_settings
|
2014-02-03 10:46:17 +00:00
|
|
|
|
|
|
|
|
|
GOOGLE_MAPS_API_KEY = 'XXXX'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@skipUnless(HAS_GEOS, 'Geos is required.')
|
2015-02-10 15:07:44 +00:00
|
|
|
|
@modify_settings(
|
|
|
|
|
INSTALLED_APPS={'append': 'django.contrib.gis'},
|
|
|
|
|
)
|
2014-02-03 10:46:17 +00:00
|
|
|
|
class GoogleMapsTest(TestCase):
|
|
|
|
|
|
2014-02-03 15:22:10 +00:00
|
|
|
|
@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)
|
|
|
|
|
|
2014-02-03 10:46:17 +00:00
|
|
|
|
@override_settings(GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY)
|
|
|
|
|
def test_unicode_in_google_maps(self):
|
|
|
|
|
"""
|
2014-03-02 14:25:53 +00:00
|
|
|
|
Test that GoogleMap doesn't crash with non-ASCII content.
|
2014-02-03 10:46:17 +00:00
|
|
|
|
"""
|
2014-02-05 20:15:47 +00:00
|
|
|
|
from django.contrib.gis.geos import Point
|
2014-02-03 10:46:17 +00:00
|
|
|
|
from django.contrib.gis.maps.google.gmap import GoogleMap, GMarker
|
|
|
|
|
|
|
|
|
|
center = Point(6.146805, 46.227574)
|
|
|
|
|
marker = GMarker(center,
|
|
|
|
|
title='En français !')
|
|
|
|
|
google_map = GoogleMap(center=center, zoom=18, markers=[marker])
|
|
|
|
|
self.assertIn("En français", google_map.scripts)
|