Skip to content

Commit f7c1443

Browse files
committed
changelog entry and test
1 parent 69fcbab commit f7c1443

2 files changed

Lines changed: 41 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Support for querying OS images by instance type via `verda.images.get(instance_type=...)`
13+
14+
### Changed
15+
16+
- Refactored `Image` model to use `@dataclass` and `@dataclass_json` for consistency with `Instance` and `Volume`
17+
1018
## [1.24.0] - 2026-03-30
1119

1220
### Added

tests/unit_tests/images/test_images.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import responses # https://github.com/getsentry/responses
2+
from responses import matchers
23

34
from verda.images import Image, ImagesService
45

6+
IMAGE_RESPONSE = {
7+
'id': '0888da25-bb0d-41cc-a191-dccae45d96fd',
8+
'name': 'Ubuntu 20.04 + CUDA 11.0',
9+
'details': ['Ubuntu 20.04', 'CUDA 11.0'],
10+
'image_type': 'ubuntu-20.04-cuda-11.0',
11+
}
12+
513

614
def test_images(http_client):
7-
# arrange - add response mock
15+
# arrange
816
responses.add(
917
responses.GET,
1018
http_client._base_url + '/images',
11-
json=[
12-
{
13-
'id': '0888da25-bb0d-41cc-a191-dccae45d96fd',
14-
'name': 'Ubuntu 20.04 + CUDA 11.0',
15-
'details': ['Ubuntu 20.04', 'CUDA 11.0'],
16-
'image_type': 'ubuntu-20.04-cuda-11.0',
17-
}
18-
],
19+
json=[IMAGE_RESPONSE],
1920
status=200,
2021
)
2122

@@ -34,4 +35,26 @@ def test_images(http_client):
3435
assert isinstance(images[0].details, list)
3536
assert images[0].details[0] == 'Ubuntu 20.04'
3637
assert images[0].details[1] == 'CUDA 11.0'
37-
assert isinstance(images[0].__str__(), str)
38+
39+
40+
def test_images_filter_by_instance_type(http_client):
41+
# arrange
42+
responses.add(
43+
responses.GET,
44+
http_client._base_url + '/images',
45+
match=[matchers.query_param_matcher({'instance_type': '1A100.22V'})],
46+
json=[IMAGE_RESPONSE],
47+
status=200,
48+
)
49+
50+
image_service = ImagesService(http_client)
51+
52+
# act
53+
images = image_service.get(instance_type='1A100.22V')
54+
55+
# assert
56+
assert isinstance(images, list)
57+
assert len(images) == 1
58+
assert isinstance(images[0], Image)
59+
assert images[0].id == '0888da25-bb0d-41cc-a191-dccae45d96fd'
60+
assert images[0].image_type == 'ubuntu-20.04-cuda-11.0'

0 commit comments

Comments
 (0)