Skip to content

Commit bbd03db

Browse files
committed
fixup! fixup! fixup! chore(python-sdk): Update tests
1 parent c580ff6 commit bbd03db

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

tests/aignostics/application/utils_test.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
TEST_MAPPING_TIFF_HE = ".*\\.tiff:staining_method=H&E"
4646
SUBMITTED_BY = "user@example.com"
47+
_ISO_8601_FORMAT = "%Y-%m-%dT%H:%M:%S"
4748

4849

4950
def _make_statistics( # noqa: PLR0913
@@ -978,11 +979,6 @@ def test_retrieve_and_print_run_details_default_is_detailed(mock_console: Mock)
978979
assert "Artifact ID" in all_output
979980

980981

981-
# Tests for validate_due_date, validate_deadline, validate_scheduling_constraints
982-
983-
_ISO_8601_FORMAT = "%Y-%m-%dT%H:%M:%S"
984-
985-
986982
@pytest.mark.unit
987983
def test_validate_due_date_none() -> None:
988984
"""Test that None is accepted (optional parameter)."""
@@ -1000,7 +996,7 @@ def test_validate_due_date_valid_formats() -> None:
1000996
future_time.isoformat(), # With timezone offset like +00:00
1001997
future_time.strftime(_ISO_8601_FORMAT) + "Z", # With Z suffix
1002998
future_time.strftime(f"{_ISO_8601_FORMAT}.%f") + "Z", # With microseconds and Z
1003-
future_time.strftime(f"{_ISO_8601_FORMAT}.%f%z"), # With microseconds and timezone
999+
future_time.strftime(f"{_ISO_8601_FORMAT}.%f") + "+00:00", # With microseconds and colon-separated offset
10041000
]
10051001

10061002
for time_str in valid_formats:
@@ -1085,7 +1081,7 @@ def test_validate_deadline_valid_formats() -> None:
10851081
future_time.isoformat(),
10861082
future_time.strftime(_ISO_8601_FORMAT) + "Z",
10871083
future_time.strftime(f"{_ISO_8601_FORMAT}.%f") + "Z",
1088-
future_time.strftime(f"{_ISO_8601_FORMAT}.%f%z"),
1084+
future_time.strftime(f"{_ISO_8601_FORMAT}.%f") + "+00:00", # With microseconds and colon-separated offset
10891085
]
10901086

10911087
for time_str in valid_formats:

tests/aignostics/platform/e2e_test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,18 @@ def _submit_and_wait( # noqa: PLR0913, PLR0917
384384

385385

386386
def _resolve_run_deadline(details: RunReadResponse, sdk_metadata: RunSdkMetadata) -> datetime:
387-
"""Extract the run deadline from the API scheduling field, falling back to custom_metadata."""
387+
"""Extract the run deadline from the API scheduling field, falling back to custom_metadata.
388+
389+
Raises:
390+
ValueError: If no deadline is found in either the API scheduling field or sdk_metadata.scheduling.
391+
"""
388392
if getattr(details, "scheduling", None) is not None and getattr(details.scheduling, "deadline", None) is not None:
389393
deadline = details.scheduling.deadline
390394
return deadline if isinstance(deadline, datetime) else datetime.fromisoformat(str(deadline))
391-
return datetime.fromisoformat(sdk_metadata.scheduling.deadline)
395+
if getattr(sdk_metadata, "scheduling", None) is None or getattr(sdk_metadata.scheduling, "deadline", None) is None:
396+
msg = "No deadline found in API scheduling field or sdk_metadata.scheduling"
397+
raise ValueError(msg)
398+
return datetime.fromisoformat(str(sdk_metadata.scheduling.deadline))
392399

393400

394401
def _find_and_validate(

0 commit comments

Comments
 (0)