Skip to content

Commit 00e9721

Browse files
guerlerclaude
andcommitted
Tighten graph endpoint typing and pin 404 in API tests
- direction: Literal["backward","forward","both"] in service and manager - HistoriesService.graph annotated -> HistoryGraphResponse - Pin 404 for missing seed_scope and missing history (was loose 4xx) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 748fef1 commit 00e9721

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

lib/galaxy/managers/history_graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import json
99
import logging
1010
from typing import (
11+
Literal,
1112
Optional,
1213
Union,
1314
)
@@ -82,7 +83,7 @@ def __init__(
8283
toolbox: Optional[AbstractToolBox] = None,
8384
include_deleted: bool = False,
8485
seed: Optional[str] = None,
85-
direction: str = "both",
86+
direction: Literal["backward", "forward", "both"] = "both",
8687
depth: int = 5,
8788
seed_scope_hid: Optional[int] = None,
8889
):

lib/galaxy/webapps/galaxy/services/histories.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
)
5555
from galaxy.schema.fields import DecodedDatabaseIdField
5656
from galaxy.schema.history import HistoryIndexQueryPayload
57+
from galaxy.schema.history_graph import HistoryGraphResponse
5758
from galaxy.schema.schema import (
5859
AnyArchivedHistoryView,
5960
AnyHistoryView,
@@ -390,10 +391,10 @@ def graph(
390391
limit: int = 500,
391392
include_deleted: bool = False,
392393
seed: Optional[str] = None,
393-
direction: str = "both",
394+
direction: Literal["backward", "forward", "both"] = "both",
394395
depth: int = 20,
395396
seed_scope: Optional[str] = None,
396-
):
397+
) -> HistoryGraphResponse:
397398
history = self.manager.get_accessible(history_id, trans.user, current_history=trans.history)
398399
seed_scope_hid = self._resolve_seed_scope_hid(trans, history.id, seed_scope) if seed_scope else None
399400
builder = HistoryGraphBuilder(

lib/galaxy_test/api/test_histories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ def test_seed_scope_not_in_target_history_is_rejected(self):
13221322
dataset = self.dataset_populator.new_dataset(source_history, content="a", wait=True)
13231323
target_history = self.dataset_populator.new_history()
13241324
response = self.dataset_populator.get_history_graph_raw(target_history, seed_scope=f"d{dataset['id']}")
1325-
assert 400 <= response.status_code < 500
1325+
self._assert_status_code_is(response, 404)
13261326

13271327
# ── auth ──
13281328

@@ -1334,4 +1334,4 @@ def test_other_users_history_is_forbidden(self):
13341334

13351335
def test_nonexistent_history_is_rejected(self):
13361336
response = self.dataset_populator.get_history_graph_raw("0000000000000000")
1337-
assert 400 <= response.status_code < 500
1337+
self._assert_status_code_is(response, 404)

0 commit comments

Comments
 (0)