This repository was archived by the owner on Jan 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
client lease improvements #704
Merged
mangelajo
merged 9 commits into
jumpstarter-dev:main
from
michalskrivanek:lease-monitor
Oct 16, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3f9449b
improve client's lease monitoring
michalskrivanek 68f44f6
support creating and updating lease's begin_time
michalskrivanek f1a1aec
show lease expected release time instead of start time
michalskrivanek 97b31dc
add pydantic validation and normalize durations to always include tim…
michalskrivanek 3abd886
use effective_end_time for lease calculations when available
michalskrivanek 6d94924
add --all to "get leases"
michalskrivanek 160db62
rename and fix protobuf generation Makefile target
michalskrivanek b2ce590
Regenerate protobuf
michalskrivanek c788991
Merge branch 'main' into lease-monitor
mangelajo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| from datetime import datetime, timedelta, timezone | ||
|
|
||
| import click | ||
| import pytest | ||
|
|
||
| from jumpstarter_cli.common import DATETIME, DURATION, DateTimeParamType, DurationParamType | ||
|
|
||
|
|
||
| class TestDateTimeParamType: | ||
| """Test DateTimeParamType parameter parsing and normalization.""" | ||
|
|
||
| def test_parse_iso8601_with_timezone(self): | ||
| """Test parsing ISO 8601 datetime with timezone.""" | ||
| dt = DATETIME.convert("2024-01-01T12:00:00Z", None, None) | ||
| assert dt.year == 2024 | ||
| assert dt.month == 1 | ||
| assert dt.day == 1 | ||
| assert dt.hour == 12 | ||
| assert dt.minute == 0 | ||
| assert dt.second == 0 | ||
| assert dt.tzinfo is not None | ||
| assert dt.tzinfo == timezone.utc | ||
|
|
||
| def test_parse_iso8601_naive_gets_normalized(self): | ||
| """Test that naive datetime gets normalized to local timezone.""" | ||
| dt = DATETIME.convert("2024-01-01T12:00:00", None, None) | ||
| assert dt.year == 2024 | ||
| assert dt.month == 1 | ||
| assert dt.day == 1 | ||
| assert dt.hour == 12 | ||
| assert dt.minute == 0 | ||
| assert dt.second == 0 | ||
| # Should have been normalized to local timezone | ||
| assert dt.tzinfo is not None | ||
|
|
||
| def test_pass_through_datetime_object_with_timezone(self): | ||
| """Test that datetime object with timezone passes through.""" | ||
| input_dt = datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc) | ||
| dt = DATETIME.convert(input_dt, None, None) | ||
| assert dt == input_dt | ||
| assert dt.tzinfo == timezone.utc | ||
|
|
||
| def test_pass_through_datetime_object_naive_gets_normalized(self): | ||
| """Test that naive datetime object gets normalized.""" | ||
| input_dt = datetime(2024, 1, 1, 12, 0, 0) # Naive | ||
| dt = DATETIME.convert(input_dt, None, None) | ||
| assert dt.year == 2024 | ||
| assert dt.month == 1 | ||
| assert dt.day == 1 | ||
| assert dt.hour == 12 | ||
| # Should have been normalized to local timezone | ||
| assert dt.tzinfo is not None | ||
|
|
||
| def test_invalid_datetime_raises_click_exception(self): | ||
| """Test that invalid datetime string raises click exception.""" | ||
| param_type = DateTimeParamType() | ||
| with pytest.raises(click.BadParameter, match="is not a valid datetime"): | ||
| param_type.convert("not-a-datetime", None, None) | ||
|
|
||
|
|
||
| class TestDurationParamType: | ||
| """Test DurationParamType parameter parsing.""" | ||
|
|
||
| def test_parse_iso8601_duration(self): | ||
| """Test parsing ISO 8601 duration.""" | ||
| td = DURATION.convert("PT1H30M", None, None) | ||
| assert td == timedelta(hours=1, minutes=30) | ||
|
|
||
| def test_parse_time_format(self): | ||
| """Test parsing HH:MM:SS format.""" | ||
| td = DURATION.convert("01:30:00", None, None) | ||
| assert td == timedelta(hours=1, minutes=30) | ||
|
|
||
| def test_parse_days_and_time(self): | ||
| """Test parsing 'D days, HH:MM:SS' format.""" | ||
| td = DURATION.convert("2 days, 01:30:00", None, None) | ||
| assert td == timedelta(days=2, hours=1, minutes=30) | ||
|
|
||
| def test_pass_through_timedelta_object(self): | ||
| """Test that timedelta object passes through.""" | ||
| input_td = timedelta(hours=1, minutes=30) | ||
| td = DURATION.convert(input_td, None, None) | ||
| assert td == input_td | ||
|
|
||
| def test_invalid_duration_raises_click_exception(self): | ||
| """Test that invalid duration string raises click exception.""" | ||
| param_type = DurationParamType() | ||
| with pytest.raises(click.BadParameter, match="is not a valid duration"): | ||
| param_type.convert("not-a-duration", None, None) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.