export_import: unknown component in urls (#88085)
gitea/chrono/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2024-03-14 10:23:11 +01:00 committed by Lauréline Guérin
parent 4add868dd9
commit 2187bf3dde
2 changed files with 10 additions and 2 deletions

View File

@ -156,7 +156,7 @@ class ExportComponent(GenericAPIView):
def get(self, request, slug, *args, **kwargs):
klass = klasses[kwargs['component_type']]
serialisation = klass.objects.get(slug=slug).export_json()
serialisation = get_object_or_404(klass, slug=slug).export_json()
return Response({'data': serialisation})
@ -168,7 +168,7 @@ class ComponentDependencies(GenericAPIView):
def get(self, request, slug, *args, **kwargs):
klass = klasses[kwargs['component_type']]
component = klass.objects.get(slug=slug)
component = get_object_or_404(klass, slug=slug)
def dependency_dict(element):
return get_component_bundle_entry(request, element)

View File

@ -189,6 +189,9 @@ def test_export_minor_components(app, user):
resp = app.get('/api/export-import/unavailability_calendars/foo/')
assert resp.json['data']['label'] == 'Foo'
# unknown component
app.get('/api/export-import/agendas/foo/', status=404)
def test_agenda_dependencies_category(app, user):
app.authorization = ('Basic', ('john.doe', 'password'))
@ -352,6 +355,11 @@ def test_agenda_dependencies_events_type(app, user):
}
def test_unknown_compoment_dependencies(app, user):
app.authorization = ('Basic', ('john.doe', 'password'))
app.get('/api/export-import/agendas/foo/dependencies/', status=404)
def test_redirect(app, user):
app.authorization = ('Basic', ('john.doe', 'password'))
agenda = Agenda.objects.create(label='Rdv', slug='rdv', kind='meetings')