diff --git a/amt/api/routes/algorithm.py b/amt/api/routes/algorithm.py index b2d38a1d..b482820c 100644 --- a/amt/api/routes/algorithm.py +++ b/amt/api/routes/algorithm.py @@ -428,6 +428,9 @@ async def find_requirement_tasks_by_measure_urn(system_card: SystemCard, measure measure = await measures_service.fetch_measures(measure_urn) for requirement_urn in measure[0].links: # TODO: This is because measure are linked to too many requirement not applicable in our use case + if requirement_urn not in requirement_mapper: + continue + if len(await requirements_service.fetch_requirements(requirement_urn)) > 0: requirement_tasks.append(requirement_mapper[requirement_urn]) diff --git a/tests/api/routes/test_algorithm.py b/tests/api/routes/test_algorithm.py index 6e84e90b..c83344b4 100644 --- a/tests/api/routes/test_algorithm.py +++ b/tests/api/routes/test_algorithm.py @@ -525,14 +525,6 @@ async def test_find_requirement_tasks_by_measure_urn() -> None: requirement_tasks = await find_requirement_tasks_by_measure_urn(test_algorithm.system_card, "urn:nl:ak:mtr:dat-01") assert len(requirement_tasks) == 2 - # empty requirements - test_algorithm.system_card.requirements = [] - with pytest.raises(KeyError): - # TODO: this is because it is not coded well change later - requirement_tasks = await find_requirement_tasks_by_measure_urn( - test_algorithm.system_card, "urn:nl:ak:mtr:dat-01" - ) - @pytest.mark.asyncio async def test_get_measure(client: AsyncClient, db: DatabaseTestUtils) -> None: