def test_render_returns_blank_for_value_when_none(self): widget = GoogleMapsAddressWidget() results = widget.render('name', None, attrs={'a1': 1, 'a2': 2}) expected = '<input a1="1" a2="2" name="name" type="text" />' expected += '<div class="map_canvas_wrapper">' expected += '<div id="map_canvas"></div></div>' self.assertEqual(expected, results)
def test_render_returns_xxxxxxx(self): widget = GoogleMapsAddressWidget() results = widget.render('name', 'value', attrs={'a1': 1, 'a2': 2}) expected = '<input a1="1" a2="2" name="name" type="text" value="value" />' expected += '<div class="map_canvas_wrapper">' expected += '<div id="map_canvas"></div></div>' self.assertHTMLEqual(expected, results)
def test_render_returns_xxxxxxx(self): widget = GoogleMapsAddressWidget() results = widget.render('name', 'value', attrs={'a1': 1, 'a2': 2}) expected = '<input a1="1" a2="2" name="name" type="text" value="value" />' expected += '<div class="map_canvas_wrapper">' expected += '<div id="map_canvas"></div></div>' self.assertEqual(expected, results)
def test_render_returns_blank_for_value_when_none(self): widget = GoogleMapsAddressWidget() results = widget.render('name', None, attrs={'a1': 1, 'a2': 2}) expected = '<input a1="1" a2="2" name="name" type="text" />' expected += '<div class="map_canvas_wrapper">' expected += '<div id="map_canvas"></div></div>' self.assertHTMLEqual(expected, results)
class Meta: model = Order fields = ['employee_order', 'address', 'geolocation'] widgets = { "address": GoogleMapsAddressWidget( attrs={ 'data-map-type': 'roadmap', 'data-autocomplete-options': json.dumps({ 'types': ['geocode', 'establishment'], 'componentRestrictions': { 'country': 'NZ' } }) }), }
def test_maps_js_uses_api_key(self): widget = GoogleMapsAddressWidget() google_maps_js = "https://maps.google.com/maps/api/js?key={}".format( settings.GOOGLE_MAPS_API_KEY) self.assertEqual(google_maps_js, widget.Media().js[1])
class Meta(object): model = Product fields = ['address', 'geolocation'] widgets = { "address": GoogleMapsAddressWidget(attrs={'disabled': 'disabled'}), }