Skip to content

Commit

Permalink
Make library configuration selection predictable for patron auth inte…
Browse files Browse the repository at this point in the history
…gration self-tests. (#2058)
  • Loading branch information
tdilauro authored Sep 16, 2024
1 parent 96b10e6 commit fee4a3d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/palace/manager/api/admin/controller/patron_auth_services.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any
from typing import Any, cast

import flask
from flask import Response
Expand Down Expand Up @@ -189,6 +189,11 @@ def run_self_tests(self, integration: IntegrationConfiguration) -> dict[str, Any
def get_library_configuration(
integration: IntegrationConfiguration,
) -> IntegrationLibraryConfiguration | None:
if not integration.library_configurations:
"""Find the first library (lowest id) associated with this service."""
if not (library_configurations := integration.library_configurations):
return None
return integration.library_configurations[0]
# We sort by library id to ensure that the result is predictable.
# We cast the library id to `int`, since mypy doesn't understand the relationship.
return sorted(
library_configurations, key=lambda config: cast(int, config.library_id)
)[0]

0 comments on commit fee4a3d

Please sign in to comment.