2017-07-07 14:54:08 +02:00
|
|
|
import copy
|
|
|
|
|
2018-12-21 23:41:11 +01:00
|
|
|
from django.contrib.gis.db.models.fields 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,
|
|
|
|
)
|
|
|
|
*_, kwargs = field.deconstruct()
|
|
|
|
self.assertEqual(kwargs, {
|
|
|
|
'srid': 4067,
|
|
|
|
'dim': 3,
|
|
|
|
'geography': True,
|
|
|
|
})
|