From 9133fdab6bb6af097a37434c113c1955fb685e0c Mon Sep 17 00:00:00 2001 From: Chatewgne Date: Tue, 6 Feb 2024 17:08:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20[CLEAN]=20Clean=20GeotrekSitePar?= =?UTF-8?q?ser=20test=20file=20(refs=20#3569)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geotrek/outdoor/parsers.py | 19 +- geotrek/outdoor/tests/test_parsers.py | 459 +------------------------- 2 files changed, 21 insertions(+), 457 deletions(-) diff --git a/geotrek/outdoor/parsers.py b/geotrek/outdoor/parsers.py index c979766ad2..87376fdc03 100644 --- a/geotrek/outdoor/parsers.py +++ b/geotrek/outdoor/parsers.py @@ -52,20 +52,29 @@ def get_id_from_mapping(self, mapping, value): return None def init_outdoor_category(self, category, model, join_field=None, extra_fields={}): + # Get categories as JSON response response = self.request_or_retry(f"{self.url}/api/v2/outdoor_{category}") results = response.json().get('results', []) + + # Init mapping variable for this category if it does not exist if category not in self.field_options.keys(): self.field_options[category] = {} if "mapping" not in self.field_options[category].keys(): self.field_options[category]["mapping"] = {} + + # Iter over category JSON results for result in results: + + # Extract label in default language from JSON label = result["name"] if isinstance(label, dict): if label[settings.MODELTRANSLATION_DEFAULT_LANGUAGE]: replaced_label = self.replace_mapping(label[settings.MODELTRANSLATION_DEFAULT_LANGUAGE], f'outdoor_{category}') else: if label: - replaced_label = self.replace_mapping(label, f'outdoor_{category}') + replaced_label = self.replace_mapping(label, f'outdoor_{category}') + + # Extract other category attributes in default language from JSON fields = {} for field in extra_fields: if isinstance(result[field], dict): @@ -73,13 +82,19 @@ def init_outdoor_category(self, category, model, join_field=None, extra_fields={ fields[field] = result[field][settings.MODELTRANSLATION_DEFAULT_LANGUAGE] else: fields[field] = result[field] + + # Extract field that will become a ForeignKey from JSON response, using mapping if join_field: mapping_key = self.replace_fields.get(join_field, join_field) mapped_value = self.get_id_from_mapping(self.field_options[mapping_key]["mapping"], result[join_field]) if not mapped_value: - continue # Ignore some results if related category was not retrieved + continue # Ignore some results if related category was not retrieved fields[f"{join_field}_id"] = mapped_value + + # Create or update object given all the fields that we extracted above category_obj, _ = model.objects.update_or_create(**{'name': replaced_label}, defaults=fields) + + # Remember this object in mapping for next call self.field_options[category]["mapping"][category_obj.pk] = result['id'] def __init__(self, *args, **kwargs): diff --git a/geotrek/outdoor/tests/test_parsers.py b/geotrek/outdoor/tests/test_parsers.py index b3278e4866..0d2bc9a80f 100644 --- a/geotrek/outdoor/tests/test_parsers.py +++ b/geotrek/outdoor/tests/test_parsers.py @@ -1,32 +1,15 @@ -from datetime import date -import json -import os -from copy import copy -from io import StringIO -from unittest import mock -from unittest import skipIf -from unittest.mock import Mock -from urllib.parse import urlparse + +from unittest import mock, skipIf from django.conf import settings -from django.contrib.gis.geos import Point, LineString, MultiLineString, WKTWriter from django.core.management import call_command -from django.core.management.base import CommandError -from django.test import TestCase, SimpleTestCase +from django.test import TestCase from django.test.utils import override_settings -from geotrek.common.utils import testdata -from geotrek.common.models import Organism, Theme, FileType, Attachment, Label +from geotrek.common.models import FileType from geotrek.common.tests.mixins import GeotrekParserTestMixin -from geotrek.core.tests.factories import PathFactory from geotrek.outdoor.models import Practice, Rating, RatingScale, Sector, Site from geotrek.outdoor.parsers import GeotrekSiteParser -from geotrek.trekking.tests.factories import RouteFactory -from geotrek.trekking.models import POI, POIType, Service, Trek, DifficultyLevel, Route -from geotrek.trekking.parsers import ( - TrekParser, GeotrekPOIParser, GeotrekServiceParser, GeotrekTrekParser, ApidaeTrekParser, ApidaeTrekThemeParser, - ApidaePOIParser, _prepare_attachment_from_apidae_illustration, RowImportError -) class TestGeotrekSiteParser(GeotrekSiteParser): @@ -52,23 +35,6 @@ class TestGeotrek2SiteParser(GeotrekSiteParser): provider = 'geotrek2' -# class TestGeotrekPOIParser(GeotrekPOIParser): # TODO IndoDesk ? WebLink ? -# url = "https://test.fr" - -# field_options = { -# 'type': {'create': True, }, -# 'geom': {'required': True}, -# } - - -# class TestGeotrekServiceParser(GeotrekServiceParser): -# url = "https://test.fr" - -# field_options = { -# 'type': {'create': True, }, -# 'geom': {'required': True}, -# } - @override_settings(MODELTRANSLATION_DEFAULT_LANGUAGE="fr") @skipIf(settings.TREKKING_TOPOLOGY_ENABLED, 'Test without dynamic segmentation only') class SiteGeotrekParserTests(GeotrekParserTestMixin, TestCase): @@ -152,420 +118,3 @@ def test_create(self, mocked_head, mocked_get): # self.assertEqual(Attachment.objects.get(object_id=site.pk, license__isnull=False).license.label, "License") child_site = Site.objects.get(name_fr="Noeud 1", name_en="Node") self.assertEqual(child_site.parent, site) - - @mock.patch('requests.get') - @mock.patch('requests.head') - def test_create_multiple_page(self, mocked_head, mocked_get): - class MockResponse: - mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_children.json'), - ('trekking', 'trek_children.json')] - mock_time = 0 - total_mock_response = 1 - - def __init__(self, status_code): - self.status_code = status_code - - def json(self): - filename = os.path.join('geotrek', self.mock_json_order[self.mock_time][0], 'tests', 'data', - 'geotrek_parser_v2', self.mock_json_order[self.mock_time][1]) - with open(filename, 'r') as f: - data_json = json.load(f) - if self.mock_json_order[self.mock_time] == 'trek.json': - data_json['count'] = 10 - if self.total_mock_response == 1: - self.total_mock_response += 1 - data_json['next'] = "foo" - self.mock_time += 1 - return data_json - - @property - def content(self): - return b'' - - # Mock GET - mocked_get.return_value = MockResponse(200) - mocked_head.return_value.status_code = 200 - - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 5) - trek = Trek.objects.all().first() - self.assertEqual(trek.name, "Boucle du Pic des Trois Seigneurs") - self.assertEqual(trek.name_it, "Foo bar") - self.assertEqual(str(trek.difficulty), 'Très facile') - self.assertEqual(str(trek.practice), 'Cheval') - self.assertAlmostEqual(trek.geom[0][0], 569946.9850365581, places=5) - self.assertAlmostEqual(trek.geom[0][1], 6190964.893167565, places=5) - self.assertEqual(trek.children.first().name, "Foo") - self.assertEqual(trek.labels.count(), 3) - self.assertEqual(trek.labels.first().name, "Chien autorisé") - self.assertEqual(Attachment.objects.filter(object_id=trek.pk).count(), 3) - self.assertEqual(Attachment.objects.get(object_id=trek.pk, license__isnull=False).license.label, "License") - - @override_settings(PAPERCLIP_MAX_BYTES_SIZE_IMAGE=1) - @mock.patch('requests.get') - @mock.patch('requests.head') - def test_create_attachment_max_size(self, mocked_head, mocked_get): - self.mock_time = 0 - self.mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_children.json')] - - # Mock GET - mocked_get.return_value.status_code = 200 - mocked_get.return_value.json = self.mock_json - mocked_get.return_value.content = b'11' - mocked_head.return_value.status_code = 200 - - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 5) - self.assertEqual(Attachment.objects.count(), 0) - - @mock.patch('requests.get') - @mock.patch('requests.head') - def test_update_attachment(self, mocked_head, mocked_get): - - class MockResponse: - mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_children.json')] - mock_time = 0 - a = 0 - - def __init__(self, status_code): - self.status_code = status_code - - def json(self): - if len(self.mock_json_order) <= self.mock_time: - self.mock_time = 0 - filename = os.path.join('geotrek', self.mock_json_order[self.mock_time][0], 'tests', 'data', - 'geotrek_parser_v2', self.mock_json_order[self.mock_time][1]) - - self.mock_time += 1 - with open(filename, 'r') as f: - return json.load(f) - - @property - def content(self): - # We change content of attachment every time - self.a += 1 - return bytes(f'{self.a}', 'utf-8') - - # Mock GET - mocked_get.return_value.status_code = 200 - mocked_get.return_value = MockResponse(200) - mocked_head.return_value.status_code = 200 - - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 5) - trek = Trek.objects.all().first() - self.assertEqual(Attachment.objects.filter(object_id=trek.pk).count(), 3) - self.assertEqual(Attachment.objects.first().attachment_file.read(), b'11') - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 5) - trek.refresh_from_db() - self.assertEqual(Attachment.objects.filter(object_id=trek.pk).count(), 3) - self.assertEqual(Attachment.objects.first().attachment_file.read(), b'13') - - @mock.patch('requests.get') - @mock.patch('requests.head') - @override_settings(MODELTRANSLATION_DEFAULT_LANGUAGE="fr") - def test_create_multiple_fr(self, mocked_head, mocked_get): - self.mock_time = 0 - self.mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_children.json'), - ('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids_2.json'), - ('trekking', 'trek_2.json'), - ('trekking', 'trek_children.json'), - ('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids_2.json'), - ('trekking', 'trek_2_after.json'), - ('trekking', 'trek_children.json'), ] - - # Mock GET - mocked_get.return_value.status_code = 200 - mocked_get.return_value.json = self.mock_json - mocked_get.return_value.content = b'' - mocked_head.return_value.status_code = 200 - - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 5) - trek = Trek.objects.all().first() - self.assertEqual(trek.name, "Boucle du Pic des Trois Seigneurs") - self.assertEqual(trek.name_en, "Loop of the pic of 3 lords") - self.assertEqual(trek.name_fr, "Boucle du Pic des Trois Seigneurs") - self.assertEqual(str(trek.difficulty), 'Très facile') - self.assertEqual(str(trek.practice), 'Cheval') - self.assertAlmostEqual(trek.geom[0][0], 569946.9850365581, places=5) - self.assertAlmostEqual(trek.geom[0][1], 6190964.893167565, places=5) - self.assertEqual(trek.children.first().name, "Foo") - self.assertEqual(trek.labels.count(), 3) - self.assertEqual(trek.labels.first().name, "Chien autorisé") - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrek2TrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 6) - trek = Trek.objects.get(name_fr="Étangs du Picot") - self.assertEqual(trek.description_teaser_fr, "Chapeau") - self.assertEqual(trek.description_teaser_it, "Cappello") - self.assertEqual(trek.description_teaser_es, "Chapeau") - self.assertEqual(trek.description_teaser_en, "Cap") - self.assertEqual(trek.description_teaser, "Chapeau") - self.assertEqual(trek.published, True) - self.assertEqual(trek.published_fr, True) - self.assertEqual(trek.published_en, False) - self.assertEqual(trek.published_it, False) - self.assertEqual(trek.published_es, False) - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrek2TrekParser', verbosity=0) - trek.refresh_from_db() - self.assertEqual(Trek.objects.count(), 6) - self.assertEqual(trek.description_teaser_fr, "Chapeau 2") - self.assertEqual(trek.description_teaser_it, "Cappello 2") - self.assertEqual(trek.description_teaser_es, "Sombrero 2") - self.assertEqual(trek.description_teaser_en, "Cap 2") - self.assertEqual(trek.description_teaser, "Chapeau 2") - self.assertEqual(trek.published, True) - self.assertEqual(trek.published_fr, True) - self.assertEqual(trek.published_en, False) - self.assertEqual(trek.published_it, False) - self.assertEqual(trek.published_es, False) - - @mock.patch('requests.get') - @mock.patch('requests.head') - @override_settings(MODELTRANSLATION_DEFAULT_LANGUAGE="en") - def test_create_multiple_en(self, mocked_head, mocked_get): - self.mock_time = 0 - self.mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_children.json'), - ('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids_2.json'), - ('trekking', 'trek_2.json'), - ('trekking', 'trek_children.json'), - ('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids_2.json'), - ('trekking', 'trek_2_after.json'), - ('trekking', 'trek_children.json')] - - # Mock GET - mocked_get.return_value.status_code = 200 - mocked_get.return_value.json = self.mock_json - mocked_get.return_value.content = b'' - mocked_head.return_value.status_code = 200 - - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 5) - trek = Trek.objects.get(name_fr="Boucle du Pic des Trois Seigneurs") - self.assertEqual(trek.name, "Loop of the pic of 3 lords") - self.assertEqual(trek.name_en, "Loop of the pic of 3 lords") - self.assertEqual(trek.name_fr, "Boucle du Pic des Trois Seigneurs") - self.assertEqual(str(trek.difficulty), 'Very easy') - self.assertEqual(str(trek.difficulty.difficulty_en), 'Very easy') - self.assertEqual(str(trek.practice), 'Horse') - self.assertAlmostEqual(trek.geom[0][0], 569946.9850365581, places=5) - self.assertAlmostEqual(trek.geom[0][1], 6190964.893167565, places=5) - self.assertEqual(trek.children.first().name, "Bar") - self.assertEqual(trek.labels.count(), 3) - self.assertEqual(trek.labels.first().name, "Dogs are great") - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrek2TrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 6) - trek = Trek.objects.get(name_fr="Étangs du Picot") - self.assertEqual(trek.description_teaser_fr, "Chapeau") - self.assertEqual(trek.description_teaser_it, "Cappello") - self.assertEqual(trek.description_teaser_es, "Cap") - self.assertEqual(trek.description_teaser_en, "Cap") - self.assertEqual(trek.description_teaser, "Cap") - self.assertEqual(trek.published, False) - self.assertEqual(trek.published_fr, True) - self.assertEqual(trek.published_en, False) - self.assertEqual(trek.published_it, False) - self.assertEqual(trek.published_es, False) - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrek2TrekParser', verbosity=0) - trek.refresh_from_db() - self.assertEqual(Trek.objects.count(), 6) - self.assertEqual(trek.description_teaser_fr, "Chapeau 2") - self.assertEqual(trek.description_teaser_it, "Cappello 2") - self.assertEqual(trek.description_teaser_es, "Sombrero 2") - self.assertEqual(trek.description_teaser_en, "Cap 2") - self.assertEqual(trek.description_teaser, "Cap 2") - self.assertEqual(trek.published, False) - self.assertEqual(trek.published_fr, True) - self.assertEqual(trek.published_en, False) - self.assertEqual(trek.published_it, False) - self.assertEqual(trek.published_es, False) - - @mock.patch('requests.get') - @mock.patch('requests.head') - def test_children_do_not_exist(self, mocked_head, mocked_get): - self.mock_time = 0 - self.mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_children_do_not_exist.json')] - - # Mock GET - mocked_get.return_value.status_code = 200 - mocked_get.return_value.json = self.mock_json - mocked_get.return_value.content = b'' - mocked_head.return_value.status_code = 200 - output = StringIO() - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=2, - stdout=output) - self.assertIn("One trek has not be generated for Boucle du Pic des Trois Seigneurs : could not find trek with UUID c9567576-2934-43ab-666e-e13d02c671a9,\n", output.getvalue()) - self.assertIn("Trying to retrieve children for missing trek : could not find trek with UUID b2aea666-5e6e-4daa-a750-7d2ee52d3fe1", output.getvalue()) - - @mock.patch('requests.get') - @mock.patch('requests.head') - def test_wrong_children_error(self, mocked_head, mocked_get): - self.mock_time = 0 - self.mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_wrong_children.json'), ] - - # Mock GET - mocked_get.return_value.status_code = 200 - mocked_get.return_value.json = self.mock_json - mocked_get.return_value.content = b'' - mocked_head.return_value.status_code = 200 - output = StringIO() - - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=2, - stdout=output) - self.assertIn("An error occured in children generation : KeyError('steps'", output.getvalue()) - - @mock.patch('requests.get') - @mock.patch('requests.head') - @override_settings(MODELTRANSLATION_DEFAULT_LANGUAGE="fr") - def test_updated(self, mocked_head, mocked_get): - self.mock_time = 0 - self.mock_json_order = [('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids.json'), - ('trekking', 'trek.json'), - ('trekking', 'trek_children.json'), - ('trekking', 'trek_difficulty.json'), - ('trekking', 'trek_route.json'), - ('trekking', 'trek_theme.json'), - ('trekking', 'trek_practice.json'), - ('trekking', 'trek_accessibility.json'), - ('trekking', 'trek_network.json'), - ('trekking', 'trek_label.json'), - ('trekking', 'sources.json'), - ('trekking', 'trek_ids_2.json'), - ('trekking', 'trek_2.json'), - ('trekking', 'trek_children.json')] - - # Mock GET - mocked_get.return_value.status_code = 200 - mocked_get.return_value.json = self.mock_json - mocked_get.return_value.content = b'' - mocked_head.return_value.status_code = 200 - - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - self.assertEqual(Trek.objects.count(), 5) - trek = Trek.objects.all().first() - self.assertEqual(trek.name, "Boucle du Pic des Trois Seigneurs") - self.assertEqual(trek.name_fr, "Boucle du Pic des Trois Seigneurs") - self.assertEqual(trek.name_en, "Loop of the pic of 3 lords") - self.assertEqual(str(trek.difficulty), 'Très facile') - self.assertEqual(str(trek.practice), 'Cheval') - self.assertAlmostEqual(trek.geom[0][0], 569946.9850365581, places=5) - self.assertAlmostEqual(trek.geom[0][1], 6190964.893167565, places=5) - self.assertEqual(trek.children.first().name, "Foo") - self.assertEqual(trek.labels.count(), 3) - self.assertEqual(trek.labels.first().name, "Chien autorisé") - call_command('import', 'geotrek.trekking.tests.test_parsers.TestGeotrekTrekParser', verbosity=0) - # Trek 2 is still in ids (trek_ids_2) => it's not removed - self.assertEqual(Trek.objects.count(), 2) - trek = Trek.objects.all().first() - self.assertEqual(trek.name, "Boucle du Pic des Trois Seigneurs")