def test_osm_field_with_args(self): field = OSMField(lat_field="some_lat_field", lon_field="some_lon_field") field.set_attributes_from_name("location") name, path, args, kwargs = field.deconstruct() self.assertEqual(name, "location") self.assertEqual(path, "osm_field.fields.OSMField") self.assertEqual(args, []) self.assertEqual( kwargs, {"lat_field": "some_lat_field", "lon_field": "some_lon_field"} )
def test_osm_field_different_names(self): field = OSMField(lat_field='some_lat_field', lon_field='some_lon_field') field.set_attributes_from_name("location") formfield = field.formfield() self.assertIsInstance(formfield.widget, OSMWidget) self.assertEqual(formfield.widget.attrs, { 'class': 'osmfield', 'data-lat-field': 'some_lat_field', 'data-lon-field': 'some_lon_field', })
def test_osm_field(self): field = OSMField() field.set_attributes_from_name("location") formfield = field.formfield() self.assertIsInstance(formfield.widget, OSMWidget) self.assertEqual(formfield.widget.attrs, { 'class': 'osmfield', 'data-lat-field': 'location_lat', 'data-lon-field': 'location_lon', })
def test_osm_field_different_names(self): field = OSMField(lat_field='some_lat_field', lon_field='some_lon_field') field.set_attributes_from_name("location") formfield = field.formfield() self.assertIsInstance(formfield.widget, OSMWidget) self.assertEqual(formfield.widget.attrs, { 'class': 'osmfield', 'data-lat-field': 'some_lat_field', 'data-lon-field': 'some_lon_field', })
def test_osm_field(self): field = OSMField() field.set_attributes_from_name("location") formfield = field.formfield() self.assertIsInstance(formfield.widget, OSMWidget) self.assertEqual(formfield.widget.attrs, { 'class': 'osmfield', 'data-lat-field': 'location_lat', 'data-lon-field': 'location_lon', })
def test_osm_field_with_args(self): field = OSMField(lat_field='some_lat_field', lon_field='some_lon_field') field.set_attributes_from_name("location") name, path, args, kwargs = field.deconstruct() self.assertEqual(name, 'location') self.assertEqual(path, 'osm_field.fields.OSMField') self.assertEqual(args, []) self.assertEqual(kwargs, { 'lat_field': 'some_lat_field', 'lon_field': 'some_lon_field', })
def test_osm_field_with_args(self): field = OSMField(lat_field='some_lat_field', lon_field='some_lon_field') field.set_attributes_from_name("location") name, path, args, kwargs = field.deconstruct() self.assertEqual(name, 'location') self.assertEqual(path, 'osm_field.fields.OSMField') self.assertEqual(args, []) self.assertEqual(kwargs, { 'lat_field': 'some_lat_field', 'lon_field': 'some_lon_field', })
def test_osm_field_different_names(self): field = OSMField(lat_field="some_lat_field", lon_field="some_lon_field") field.set_attributes_from_name("location") formfield = field.formfield() self.assertIsInstance(formfield.widget, OSMWidget) self.assertEqual( formfield.widget.attrs, { "class": "osmfield", "data-lat-field": "some_lat_field", "data-lon-field": "some_lon_field", }, )