@@ -0,0 +1,2984 @@
+from django.test import TestCase%0A%0Afrom django.contrib.contenttypes.models import ContentType%0Afrom django.db import connection%0A%0Afrom geotrek.authent.tests.factories import StructureFactory%0Afrom geotrek.core.models import Path, PathAggregation, Topology, Trail%0Afrom geotrek.core.tests.factories import PathFactory, TopologyFactory%0Afrom geotrek.common.tests.factories import FileTypeFactory%0Afrom geotrek.trekking.tests.factories import TrekFactory%0Afrom geotrek.authent.tests.factories import UserFactory%0A%0A%0Aclass SQLDefaultValuesTest(TestCase):%0A    def test_path(self):%0A        path = PathFactory.build()%0A        structure = StructureFactory.create()%0A        with connection.cursor() as cur:%0A            cur.execute(f%22%22%22INSERT INTO core_path%0A                           (%0A                           geom,%0A                           structure_id%0A                           ) VALUES%0A                           (%0A                           ST_GeomFromEWKT(%5C'%7Bpath.geom.ewkt%7D%5C'),%0A                           %7Bstructure.pk%7D%0A                           )%22%22%22)%0A        path = Path.objects.first()%0A        self.assertTrue(path.valid)%0A%0A    def test_topology(self):%0A        path = PathFactory.create()%0A        with connection.cursor() as cur:%0A            cur.execute(f%22%22%22INSERT INTO core_topology DEFAULT VALUES%22%22%22)%0A%0A        topology = Topology.objects.first()%0A        topology.add_path(path, 0, 1)%0A        self.assertEqual(topology.geom, path.geom)%0A        self.assertEqual(topology.kind, '')%0A%0A    def test_pathaggregation(self):%0A        path = PathFactory.create()%0A        topology = TopologyFactory.create(paths=%5B%5D)%0A        self.assertIsNone(topology.geom)%0A        with connection.cursor() as cur:%0A            cur.execute(f%22%22%22INSERT INTO core_pathaggregation%0A                           (%0A                           path_id,%0A                           topo_object_id%0A                           ) VALUES%0A                           (%0A                           %7Bpath.pk%7D,%0A                           %7Btopology.pk%7D%0A                           )%22%22%22)%0A        topology.reload()%0A        first, last = path.geom.boundary%0A        self.assertEqual(topology.geom, first)%0A        path_aggregation = PathAggregation.objects.first()%0A        self.assertEqual(path_aggregation.order, 0)%0A%0A    def test_trail(self):%0A        topology = TopologyFactory.create()%0A        structure = StructureFactory.create()%0A        with connection.cursor() as cur:%0A            cur.execute(f%22%22%22INSERT INTO core_trail%0A                                  (%0A                                  name,%0A                                  topo_object_id,%0A                                  structure_id%0A                                  ) VALUES%0A                                  (%0A                                  'name_trail',%0A                                  %7Btopology.pk%7D,%0A                                  %7Bstructure.pk%7D%0A                                  )%22%22%22)%0A        trail = Trail.objects.first()%0A        self.assertEqual(trail.departure, '')%0A

Add test sql core