Skip to content

Commit

Permalink
Add unit test for url update when description is null or missing
Browse files Browse the repository at this point in the history
  • Loading branch information
justinefricou committed Nov 15, 2024
1 parent 31aa50c commit 5d1be49
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 ] ]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -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 ] ]
}
}
]
}
9 changes: 9 additions & 0 deletions geotrek/trekking/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<a data-schemarandonneeparser-url href=https://test.com>https://test.com</a>")
self.assertEqual(trek2.description, "<a data-schemarandonneeparser-url href=https://test.com>https://test.com</a>")

0 comments on commit 5d1be49

Please sign in to comment.