def test_clean(self): field = SpatialLocationField() point = field.clean("12,13") self.assertIsInstance(point, Point) self.assertEqual(point.x, 13) self.assertEqual(point.y, 12) point = field.clean("12") self.assertIsNone(point)
def test_to_python(self): field = SpatialLocationField() for empty in field.empty_values: self.assertIsNone(field.to_python(empty)) point = Point(12, 13) self.assertIs(point, field.to_python(point)) point = field.to_python("12,13") self.assertIsInstance(point, Point) self.assertEqual(point.x, 13) self.assertEqual(point.y, 12)
def test_passing_map_attrs(self): field = SpatialLocationField(map_attrs={ "some": "value", "and some": "cool value" }) self.assertEqual(field.widget.map_attrs, { "some": "value", "and some": "cool value" })
def test_error_messages(self): field = SpatialLocationField() self.assertEqual(field.error_messages["required"], "Please pick a location, it's required")
def test_widget(self): field = SpatialLocationField() self.assertEqual(field.widget.__class__, MapInput().__class__)