コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
 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"
     })
コード例 #4
0
 def test_error_messages(self):
     field = SpatialLocationField()
     self.assertEqual(field.error_messages["required"],
                      "Please pick a location, it's required")
コード例 #5
0
 def test_widget(self):
     field = SpatialLocationField()
     self.assertEqual(field.widget.__class__, MapInput().__class__)