2017-07-07 12:54:08 +00:00
|
|
|
import copy
|
|
|
|
|
2019-08-20 07:54:41 +00:00
|
|
|
from django.contrib.gis.db.models import GeometryField
|
2017-07-07 12:54:08 +00: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 15:56:39 +00:00
|
|
|
field = AreaField(None)
|
2017-07-07 12:54:08 +00:00
|
|
|
self.assertEqual(copy.deepcopy(field), field)
|
|
|
|
|
|
|
|
def test_distance_field_deepcopy(self):
|
2017-09-11 15:56:39 +00:00
|
|
|
field = DistanceField(None)
|
2017-07-07 12:54:08 +00:00
|
|
|
self.assertEqual(copy.deepcopy(field), field)
|
2018-12-21 22:41:11 +00: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 22:44:34 +00:00
|
|
|
extent=(
|
|
|
|
50199.4814,
|
|
|
|
6582464.0358,
|
|
|
|
-50000.0,
|
|
|
|
761274.6247,
|
|
|
|
7799839.8902,
|
|
|
|
50000.0,
|
|
|
|
),
|
|
|
|
tolerance=0.01,
|
2018-12-21 22:41:11 +00:00
|
|
|
)
|
|
|
|
*_, kwargs = field.deconstruct()
|
|
|
|
self.assertEqual(
|
|
|
|
kwargs,
|
|
|
|
{
|
|
|
|
"srid": 4067,
|
|
|
|
"dim": 3,
|
|
|
|
"geography": True,
|
2018-12-21 22:44:34 +00:00
|
|
|
"extent": (
|
|
|
|
50199.4814,
|
|
|
|
6582464.0358,
|
|
|
|
-50000.0,
|
|
|
|
761274.6247,
|
|
|
|
7799839.8902,
|
|
|
|
50000.0,
|
|
|
|
),
|
|
|
|
"tolerance": 0.01,
|
2018-12-21 22:41:11 +00:00
|
|
|
},
|
|
|
|
)
|