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")
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
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