diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before.geojson new file mode 100644 index 0000000000..985d8354ce --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before.geojson @@ -0,0 +1,40 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "url": "https://test.com", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": null + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "2", + "producteur": "Producer 1", + "url": "https://test.com", + "nom_itineraire": "Trek 2", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before_after.geojson b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before_after.geojson new file mode 100644 index 0000000000..0b7c5e8c3b --- /dev/null +++ b/geotrek/trekking/tests/data/schema_randonnee_parser/update_url_before_after.geojson @@ -0,0 +1,41 @@ +{ + "type": "FeatureCollection", + "name": "sql_statement", + "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + "features": [ + { + "type": "Feature", + "properties": { + "id_local": "1", + "producteur": "Producer 1", + "url": "https://test.com", + "nom_itineraire": "Trek 1", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 1" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + }, + { + "type": "Feature", + "properties": { + "id_local": "2", + "producteur": "Producer 1", + "url": "https://test.com", + "nom_itineraire": "Trek 2", + "pratique": "pédestre", + "depart": "Departure 1", + "arrivee": "Arrival 1", + "instructions": "Instructions 2" + }, + "geometry": { + "type": "LineString", + "coordinates": [ [ 6.449592517966364, 44.733424655086957 ], [ 6.449539623508488, 44.733394939411369 ] ] + } + } + ] +} \ No newline at end of file diff --git a/geotrek/trekking/tests/test_parsers.py b/geotrek/trekking/tests/test_parsers.py index efd61d2062..819b54e920 100644 --- a/geotrek/trekking/tests/test_parsers.py +++ b/geotrek/trekking/tests/test_parsers.py @@ -2035,3 +2035,12 @@ def test_no_url(self): self.assertEqual(Trek.objects.count(), 1) trek = Trek.objects.get() self.assertEqual(trek.description, 'Instructions 1') + + def test_update_url(self): + self.call_import_command_with_file('update_url_before.geojson') + self.call_import_command_with_file('update_url_after.geojson') + self.assertEqual(Trek.objects.count(), 2) + trek1 = Trek.objects.get(eid='1') + trek2 = Trek.objects.get(eid='2') + self.assertEqual(trek1.description, "https://test.com") + self.assertEqual(trek2.description, "https://test.com")