MCPcopy
hub / github.com/django/django / assertMapWidget

Method assertMapWidget

tests/gis_tests/test_geoforms.py:287–310  ·  view source on GitHub ↗

Make sure the MapWidget js is passed in the form media and a MapWidget is actually created

(self, form_instance, geom_name)

Source from the content-addressed store, hash-verified

285 }
286
287 def assertMapWidget(self, form_instance, geom_name):
288 """
289 Make sure the MapWidget js is passed in the form media and a MapWidget
290 is actually created
291 """
292 self.assertTrue(form_instance.is_valid())
293 rendered = form_instance.as_p()
294
295 map_fields = [
296 f for f in form_instance if isinstance(f.field, forms.GeometryField)
297 ]
298 for map_field in map_fields:
299 attrs = {
300 "base_layer": "nasaWorldview",
301 "geom_type": map_field.field.geom_type,
302 "map_srid": 3857,
303 "display_raw": False,
304 "required": True,
305 "id": map_field.id_for_label,
306 "geom_name": geom_name,
307 }
308 expected = json_script(attrs, f"{map_field.id_for_label}_mapwidget_options")
309 self.assertInHTML(expected, rendered)
310 self.assertIn("gis/js/OLMapWidget.js", str(form_instance.media))
311
312 def assertTextarea(self, geom, rendered):
313 """Makes sure the wkt and a textarea are in the content"""

Callers 7

test_pointfieldMethod · 0.95
test_multipointfieldMethod · 0.95
test_linestringfieldMethod · 0.95
test_polygonfieldMethod · 0.95

Calls 4

json_scriptFunction · 0.90
as_pMethod · 0.80
assertInHTMLMethod · 0.80
is_validMethod · 0.45

Tested by

no test coverage detected