Skip to content

Commit

Permalink
✅ [TEST] Add test for GeotrekSiteParser attachments (refs #3569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chatewgne committed Feb 6, 2024
1 parent 9133fda commit 3ca9e0b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions geotrek/common/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ class GeotrekAggregatorParser:
"TouristicEvent": ("geotrek.tourism.parsers", "GeotrekTouristicEventParser"),
"Signage": ("geotrek.signage.parsers", "GeotrekSignageParser"),
"Infrastructure": ("geotrek.infrastructure.parsers", "GeotrekInfrastructureParser"),
"Site": ("geotrek.outdoor.parsers", "GeotrekOutdoorSiteParser"),
}

invalid_model_topology = ['Trek', 'POI', 'Service', 'Signage', 'Infrastructure']
Expand Down
3 changes: 2 additions & 1 deletion geotrek/outdoor/parsers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.conf import settings
from geotrek.common.parsers import (ApidaeBaseParser, AttachmentParserMixin, GeotrekParser, GlobalImportError, Parser)

from geotrek.common.parsers import GeotrekParser
from geotrek.outdoor.models import Practice, Rating, RatingScale, Sector, Site


Expand Down
19 changes: 18 additions & 1 deletion geotrek/outdoor/tests/data/geotrek_parser_v2/outdoor_site.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,24 @@
"en": "Test ambiance en",
"fr": "Test ambiance fr"
},
"attachments": [],
"attachments": [
{
"backend": "",
"type": "image",
"filetype": {
"id": 1,
"structure": null,
"type": "Photographie"
},
"author": "",
"license": null,
"thumbnail": "https://foo.fr/media/paperclip/trekking_trek/10443/1083px-arrien-en-bethmale_general_view.JPG.400x0_q85.jpg",
"legend": "Arrien-en-Bethmale, vue du village",
"title": "",
"url": "https://foo.fr/media/paperclip/trekking_trek/10443/1083px-arrien-en-bethmale_general_view.JPG",
"uuid": "c648fff1-2416-48fa-a67d-5fbcf466f3a1"
}
],
"cities": [],
"children": [
2,
Expand Down
8 changes: 5 additions & 3 deletions geotrek/outdoor/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.test import TestCase
from django.test.utils import override_settings

from geotrek.common.models import FileType
from geotrek.common.models import Attachment, FileType
from geotrek.common.tests.mixins import GeotrekParserTestMixin
from geotrek.outdoor.models import Practice, Rating, RatingScale, Sector, Site
from geotrek.outdoor.parsers import GeotrekSiteParser
Expand Down Expand Up @@ -114,7 +114,9 @@ def test_create(self, mocked_head, mocked_get):
# self.assertEqual(site.weblink.count(), 1)
# self.assertEqual(site.excluded_pois.count(), 1)
self.assertEqual(site.eid, "57a8fb52-213d-4dce-8224-bc997f892aae")
# self.assertEqual(Attachment.objects.filter(object_id=site.pk).count(), 3)
# self.assertEqual(Attachment.objects.get(object_id=site.pk, license__isnull=False).license.label, "License")
self.assertEqual(Attachment.objects.filter(object_id=site.pk).count(), 1)
attachment = Attachment.objects.filter(object_id=site.pk).first()
self.assertIsNotNone(attachment.attachment_file.url)
self.assertEqual(attachment.legend, 'Arrien-en-Bethmale, vue du village')
child_site = Site.objects.get(name_fr="Noeud 1", name_en="Node")
self.assertEqual(child_site.parent, site)

0 comments on commit 3ca9e0b

Please sign in to comment.