tests.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from unittest import skipUnless
  4. from django.contrib.gis.geos import HAS_GEOS
  5. from django.test import TestCase
  6. from django.test.utils import override_settings
  7. GOOGLE_MAPS_API_KEY = 'XXXX'
  8. @skipUnless(HAS_GEOS, 'Geos is required.')
  9. class GoogleMapsTest(TestCase):
  10. @override_settings(GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY)
  11. def test_google_map_scripts(self):
  12. """
  13. Testing GoogleMap.scripts() output. See #20773.
  14. """
  15. from django.contrib.gis.maps.google.gmap import GoogleMap
  16. google_map = GoogleMap()
  17. scripts = google_map.scripts
  18. self.assertIn(GOOGLE_MAPS_API_KEY, scripts)
  19. self.assertIn("new GMap2", scripts)
  20. @override_settings(GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY)
  21. def test_unicode_in_google_maps(self):
  22. """
  23. Test that GoogleMap doesn't crash with non-ASCII content.
  24. """
  25. from django.contrib.gis.geos import Point
  26. from django.contrib.gis.maps.google.gmap import GoogleMap, GMarker
  27. center = Point(6.146805, 46.227574)
  28. marker = GMarker(center,
  29. title='En français !')
  30. google_map = GoogleMap(center=center, zoom=18, markers=[marker])
  31. self.assertIn("En français", google_map.scripts)