<s> from __future__ import absolute_import <EOL> from django . contrib . gis . geos import HAS_GEOS <EOL> from django . contrib . gis . tests . utils import HAS_SPATIAL_DB <EOL> from django . test import TestCase <EOL> from django . test . utils import override_settings <EOL> from django . utils . unittest import skipUnless <EOL> if HAS_GEOS and HAS_SPATIAL_DB : <EOL> from django . contrib . gis import admin <EOL> from django . contrib . gis . geos import Point <EOL> from . models import City <EOL> GOOGLE_MAPS_API_KEY = '<STR_LIT>' <EOL> @ skipUnless ( HAS_GEOS and HAS_SPATIAL_DB , "<STR_LIT>" ) <EOL> class GeoAdminTest ( TestCase ) : <EOL> urls = '<STR_LIT>' <EOL> def test_ensure_geographic_media ( self ) : <EOL> geoadmin = admin . site . _registry [ City ] <EOL> admin_js = geoadmin . media . render_js ( ) <EOL> self . assertTrue ( any ( [ geoadmin . openlayers_url in js for js in admin_js ] ) ) <EOL> def test_olmap_OSM_rendering ( self ) : <EOL> geoadmin = admin . site . _registry [ City ] <EOL> result = geoadmin . get_map_widget ( City . _meta . get_field ( '<STR_LIT>' ) ) ( <EOL> ) . render ( '<STR_LIT>' , Point ( - <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . assertIn ( <EOL> """<STR_LIT>""" , <EOL> result ) <EOL> def test_olmap_WMS_rendering ( self ) : <EOL> geoadmin = admin . GeoModelAdmin ( City , admin . site ) <EOL> result = geoadmin . get_map_widget ( City . _meta . get_field ( '<STR_LIT>' ) ) ( <EOL> ) . render ( '<STR_LIT>' , Point ( - <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . assertIn ( <EOL> """<STR_LIT>""" , <EOL> result ) <EOL> def test_olwidget_has_changed ( self ) : <EOL> """<STR_LIT>""" <EOL> geoadmin = admin . site . _registry [ City ] <EOL> form = geoadmin . get_changelist_form ( None ) ( ) <EOL> has_changed = form . fields [ '<STR_LIT>' ] . _has_changed <EOL> initial = Point ( <NUM_LIT> , <NUM_LIT> , srid = <NUM_LIT> ) <EOL> data_same = "<STR_LIT>" <EOL> data_almost_same = "<STR_LIT>" <EOL> data_changed = "<STR_LIT>" <EOL> self . assertTrue ( has_changed ( None , data_changed ) ) <EOL> self . assertTrue ( has_changed ( initial , "<STR_LIT>" ) ) <EOL> self . assertFalse ( has_changed ( None , "<STR_LIT>" ) ) <EOL> self . assertFalse ( has_changed ( initial , data_same ) ) <EOL> self . assertFalse ( has_changed ( initial , data_almost_same ) ) <EOL> self . assertTrue ( has_changed ( initial , data_changed ) ) <EOL> @ override_settings ( GOOGLE_MAPS_API_KEY = GOOGLE_MAPS_API_KEY ) <EOL> def test_google_map_scripts ( self ) : <EOL> """<STR_LIT>""" <EOL> from django . contrib . gis . maps . google . gmap import GoogleMap <EOL> google_map = GoogleMap ( ) <EOL> scripts = google_map . scripts <EOL> self . assertIn ( GOOGLE_MAPS_API_KEY , scripts ) <EOL> self . assertIn ( "<STR_LIT>" , scripts ) </s>
