-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deprecation field to Iso (#318)
See these changelog entries for the announcement: - https://docs.hetzner.cloud/changelog#2023-10-12-deprecation-info-for-isos - https://docs.hetzner.cloud/changelog#2023-10-12-field-deprecated-on-isos-is-now-deprecated
- Loading branch information
Showing
2 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,14 +1,38 @@ | ||
from __future__ import annotations | ||
|
||
import datetime | ||
from datetime import timezone | ||
from datetime import datetime, timezone | ||
|
||
import pytest | ||
|
||
from hcloud.isos import Iso | ||
|
||
|
||
class TestIso: | ||
def test_deprecated_is_datetime(self): | ||
iso = Iso(id=1, deprecated="2016-01-30T23:50+00:00") | ||
assert iso.deprecated == datetime.datetime( | ||
2016, 1, 30, 23, 50, tzinfo=timezone.utc | ||
@pytest.fixture() | ||
def deprecated_iso(self): | ||
return Iso( | ||
**{ | ||
"id": 10433, | ||
"name": "vyos-1.4-rolling-202111150317-amd64.iso", | ||
"description": "VyOS 1.4 (amd64)", | ||
"type": "public", | ||
"deprecation": { | ||
"announced": "2023-10-05T08:27:01Z", | ||
"unavailable_after": "2023-11-05T08:27:01Z", | ||
}, | ||
"architecture": "x86", | ||
"deprecated": "2023-11-05T08:27:01Z", | ||
} | ||
) | ||
|
||
def test_deprecation(self, deprecated_iso: Iso): | ||
assert deprecated_iso.deprecated == datetime( | ||
2023, 11, 5, 8, 27, 1, tzinfo=timezone.utc | ||
) | ||
assert deprecated_iso.deprecation is not None | ||
assert deprecated_iso.deprecation.announced == datetime( | ||
2023, 10, 5, 8, 27, 1, tzinfo=timezone.utc | ||
) | ||
assert deprecated_iso.deprecation.unavailable_after == datetime( | ||
2023, 11, 5, 8, 27, 1, tzinfo=timezone.utc | ||
) |