Skip to content

Commit

Permalink
Add warning and test for missing Tour parent trek
Browse files Browse the repository at this point in the history
  • Loading branch information
Chatewgne committed Sep 19, 2022
1 parent 19f6b09 commit b72044e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions geotrek/trekking/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def end(self):
if value:
trek_parent_instance = Trek.objects.filter(eid=key)
if not trek_parent_instance:
self.add_warning(_(f"Trying to retrieve children for missing trek : could not find trek with UUID {key}"))
return
order = 0
for child in value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
{
"uuid": "b2aea892-5e6e-4daa-a750-7d2ee52d3fe1",
"steps": []
},
{
"uuid": "b2aea666-5e6e-4daa-a750-7d2ee52d3fe1",
"steps": [
{
"uuid": "c9567576-2934-43ab-979e-e13d02c671a9"
}
]
}
]
}
1 change: 1 addition & 0 deletions geotrek/trekking/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def test_children_do_not_exist(self, mocked_head, mocked_get):
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')
Expand Down

0 comments on commit b72044e

Please sign in to comment.