예제 #1
0
    def test_latlng_field(self):
        f = LatLngField()
        pytest.raises(ValidationError, f.clean, None)
        pytest.raises(ValidationError, f.clean, 'a')
        pytest.raises(ValidationError, f.clean, [])
        pytest.raises(ValidationError, f.clean, [12.345])
        pytest.raises(ValidationError, f.clean, [92, 123.345])
        pytest.raises(ValidationError, f.clean, [12.345, 182])

        assert (12.345, 123.456) == f.clean((12.345, 123.456))
        assert (12.345, 123.456) == f.clean(('12.345', '123.456'))
        assert isinstance(f.clean((12.345, 123.456)), latlng)
예제 #2
0
    def test_latlng_field(self):
        f = LatLngField()
        self.assertRaises(ValidationError, f.clean, None)
        self.assertRaises(ValidationError, f.clean, 'a')
        self.assertRaises(ValidationError, f.clean, [])
        self.assertRaises(ValidationError, f.clean, [12.345])
        self.assertRaises(ValidationError, f.clean, [92, 123.345])
        self.assertRaises(ValidationError, f.clean, [12.345, 182])

        self.assertEqual((12.345, 123.456), f.clean((12.345, 123.456)))
        self.assertEqual((12.345, 123.456), f.clean(('12.345', '123.456')))
        self.assertIsInstance(f.clean((12.345, 123.456)), latlng)