Added assertion for geom_type in BaseGeometryWidget.get_context().

This commit is contained in:
Giannis Adamopoulos 2020-11-28 08:58:40 +01:00 committed by Mariusz Felisiak
parent 931c6e982c
commit 9175a2cc32
1 changed files with 5 additions and 1 deletions

View File

@ -374,10 +374,14 @@ class OSMWidgetTest(SimpleTestCase):
class GeometryWidgetTests(SimpleTestCase): class GeometryWidgetTests(SimpleTestCase):
def test_get_context_attrs(self): def test_get_context_attrs(self):
"""The Widget.get_context() attrs argument overrides self.attrs.""" # The Widget.get_context() attrs argument overrides self.attrs.
widget = BaseGeometryWidget(attrs={'geom_type': 'POINT'}) widget = BaseGeometryWidget(attrs={'geom_type': 'POINT'})
context = widget.get_context('point', None, attrs={'geom_type': 'POINT2'}) context = widget.get_context('point', None, attrs={'geom_type': 'POINT2'})
self.assertEqual(context['geom_type'], 'POINT2') self.assertEqual(context['geom_type'], 'POINT2')
# Widget.get_context() returns expected name for geom_type.
widget = BaseGeometryWidget(attrs={'geom_type': 'POLYGON'})
context = widget.get_context('polygon', None, None)
self.assertEqual(context['geom_type'], 'Polygon')
def test_subwidgets(self): def test_subwidgets(self):
widget = forms.BaseGeometryWidget() widget = forms.BaseGeometryWidget()