コード例 #1
0
    def test_parse_location(self):
        self.assertEqual(parse_location("1,7"), (1, 7))
        self.assertEqual(
            parse_location("0.5542434352,7.14325463435626543674375"),
            (0.5542434352, 7.14325463435626543674375))

        self.assertRaisesValidationError(parse_location, "1,2,4,7,6")
        self.assertRaisesValidationError(parse_location, "1")
        self.assertRaisesValidationError(parse_location, "1,xD")
        self.assertRaisesValidationError(parse_location, "xD,1")
コード例 #2
0
 def test_to_python(self):
     instance = LocationField()
     self.assertIsNone(instance.to_python(None))
     self.assertEqual(instance.to_python((1, 2)), (1, 2))
     self.assertEqual(instance.to_python("1,1"), parse_location("1,1"))  # already tested above
コード例 #3
0
 def test_from_db_value(self):
     instance = LocationField()
     self.assertIsNone(instance.from_db_value(None))
     self.assertEqual(instance.from_db_value("1,1"), parse_location("1,1"))  # already tested above