2017-07-07 14:54:08 +02:00
|
|
|
import copy
|
|
|
|
|
2019-08-20 09:54:41 +02:00
|
|
|
from django.contrib.gis.db.models import GeometryField
|
2017-07-07 14:54:08 +02:00
|
|
|
from django.contrib.gis.db.models.sql import AreaField, DistanceField
|
|
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class FieldsTests(SimpleTestCase):
|
|
|
|
def test_area_field_deepcopy(self):
|
2017-09-11 17:56:39 +02:00
|
|
|
field = AreaField(None)
|
2017-07-07 14:54:08 +02:00
|
|
|
self.assertEqual(copy.deepcopy(field), field)
|
|
|
|
|
|
|
|
def test_distance_field_deepcopy(self):
|
2017-09-11 17:56:39 +02:00
|
|
|
field = DistanceField(None)
|
2017-07-07 14:54:08 +02:00
|
|
|
self.assertEqual(copy.deepcopy(field), field)
|
2018-12-21 23:41:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
class GeometryFieldTests(SimpleTestCase):
|
|
|
|
def test_deconstruct_empty(self):
|
|
|
|
field = GeometryField()
|
|
|
|
*_, kwargs = field.deconstruct()
|
|
|
|
self.assertEqual(kwargs, {"srid": 4326})
|
|
|
|
|
|
|
|
def test_deconstruct_values(self):
|
|
|
|
field = GeometryField(
|
|
|
|
srid=4067,
|
|
|
|
dim=3,
|
|
|
|
geography=True,
|
2018-12-21 23:44:34 +01:00
|
|
|
extent=(
|
|
|
|
50199.4814,
|
|
|
|
6582464.0358,
|
|
|
|
-50000.0,
|
|
|
|
761274.6247,
|
|
|
|
7799839.8902,
|
|
|
|
50000.0,
|
|
|
|
),
|
|
|
|
tolerance=0.01,
|
2018-12-21 23:41:11 +01:00
|
|
|
)
|
|
|
|
*_, kwargs = field.deconstruct()
|
|
|
|
self.assertEqual(
|
|
|
|
kwargs,
|
|
|
|
{
|
|
|
|
"srid": 4067,
|
|
|
|
"dim": 3,
|
|
|
|
"geography": True,
|
2018-12-21 23:44:34 +01:00
|
|
|
"extent": (
|
|
|
|
50199.4814,
|
|
|
|
6582464.0358,
|
|
|
|
-50000.0,
|
|
|
|
761274.6247,
|
|
|
|
7799839.8902,
|
|
|
|
50000.0,
|
|
|
|
),
|
|
|
|
"tolerance": 0.01,
|
2018-12-21 23:41:11 +01:00
|
|
|
},
|
|
|
|
)
|