Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added missing fields to the `Volume` class: `pseudo_path`, `mount_command`, `create_directory_command`, `filesystem_to_fstab_command`, `instances`, `contract`, `base_hourly_cost`, `monthly_price`, `currency`, `long_term`

### Changed

- Refactored `Volume` class to use `@dataclass` and `@dataclass_json` for consistency with `Instance` class. `Volume.create_from_dict()` is replaced by `Volume.from_dict()`; unknown API fields are now silently ignored via `Undefined.EXCLUDE`

## [1.23.1] - 2026-03-25

### Fixed
Expand Down
24 changes: 12 additions & 12 deletions tests/unit_tests/volumes/test_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'is_os_volume': True,
'created_at': NVME_VOL_CREATED_AT,
'target': TARGET_VDA,
'ssh_key_ids': SSH_KEY_ID,
'ssh_key_ids': [SSH_KEY_ID],
'pseudo_path': 'volume-nxC2tf9F',
'mount_command': 'mount -t nfs -o nconnect=16 nfs.fin-01.datacrunch.io:volume-nxC2tf9F /mnt/volume',
'create_directory_command': 'mkdir -p /mnt/volume',
Expand Down Expand Up @@ -108,13 +108,13 @@ def endpoint(self, http_client):

def test_initialize_a_volume(self):
volume = Volume(
RANDOM_VOL_ID,
VolumeStatus.DETACHED,
HDD_VOL_NAME,
HDD_VOL_SIZE,
HDD,
False,
HDD_VOL_CREATED_AT,
id=RANDOM_VOL_ID,
status=VolumeStatus.DETACHED,
name=HDD_VOL_NAME,
size=HDD_VOL_SIZE,
type=HDD,
is_os_volume=False,
created_at=HDD_VOL_CREATED_AT,
)

assert volume.id == RANDOM_VOL_ID
Expand All @@ -129,8 +129,8 @@ def test_initialize_a_volume(self):
assert volume.target is None
assert volume.ssh_key_ids == []

def test_create_from_dict_without_new_fields(self):
"""Test that create_from_dict handles API responses missing the new fields."""
def test_from_dict_without_optional_fields(self):
"""Test that from_dict handles API responses missing optional fields."""
minimal_dict = {
'id': RANDOM_VOL_ID,
'status': VolumeStatus.DETACHED,
Expand All @@ -144,7 +144,7 @@ def test_create_from_dict_without_new_fields(self):
'instance_id': None,
'ssh_key_ids': [],
}
volume = Volume.create_from_dict(minimal_dict)
volume = Volume.from_dict(minimal_dict)
assert volume.id == RANDOM_VOL_ID
assert volume.pseudo_path is None
assert volume.mount_command is None
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_get_volumes(self, volumes_service, endpoint):
assert volume_nvme.is_os_volume
assert volume_nvme.created_at == NVME_VOL_CREATED_AT
assert volume_nvme.target == TARGET_VDA
assert volume_nvme.ssh_key_ids == SSH_KEY_ID
assert volume_nvme.ssh_key_ids == [SSH_KEY_ID]
assert volume_nvme.pseudo_path == NVME_VOLUME['pseudo_path']
assert volume_nvme.mount_command == NVME_VOLUME['mount_command']
assert volume_nvme.create_directory_command == NVME_VOLUME['create_directory_command']
Expand Down
Loading
Loading