Skip to content

Commit 8dd1532

Browse files
committed
tests: rename DecodeSample in DecodeTestSample
1 parent 3d47168 commit 8dd1532

3 files changed

Lines changed: 32 additions & 29 deletions

File tree

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pytest tests/unit_tests/ -v -k "skip"
8282
| `test_cli.py` | CLI argument parsing and option handling |
8383
| `test_skip_list.py` | Skip list pattern matching and filtering |
8484
| `test_filter_suite.py` | Test suite filtering by codec, pattern, and skip rules |
85-
| `test_sample_configs.py` | Sample configuration classes (DecodeSample, EncodeTestSample) |
85+
| `test_sample_configs.py` | Sample configuration classes (DecodeTestSample, EncodeTestSample) |
8686
| `test_status_determination.py` | Return code to test status mapping |
8787
| `test_utils.py` | Utility functions (file hashing, checksum verification) |
8888

tests/unit_tests/test_sample_configs.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Unit tests for sample configuration classes.
33
4-
Tests DecodeSample, EncodeTestSample, and CodecType.
4+
Tests DecodeTestSample, EncodeTestSample, and CodecType.
55
66
Copyright 2025 Igalia S.L.
77
@@ -21,7 +21,7 @@
2121
import pytest
2222

2323
from tests.libs.video_test_config_base import CodecType, BaseTestConfig
24-
from tests.video_test_framework_decode import DecodeSample
24+
from tests.video_test_framework_decode import DecodeTestSample
2525
from tests.video_test_framework_encode import EncodeTestSample
2626

2727

@@ -48,11 +48,11 @@ def test_codec_type_invalid_string(self):
4848
CodecType("invalid")
4949

5050

51-
class TestDecodeSample:
52-
"""Tests for DecodeSample class"""
51+
class TestDecodeTestSample:
52+
"""Tests for DecodeTestSample class"""
5353

5454
def test_from_dict_valid(self):
55-
"""Test creating DecodeSample from valid dictionary"""
55+
"""Test creating DecodeTestSample from valid dictionary"""
5656
data = {
5757
"name": "h264_test",
5858
"codec": "h264",
@@ -63,7 +63,7 @@ def test_from_dict_valid(self):
6363
"expected_output_md5": "def456",
6464
}
6565

66-
sample = DecodeSample.from_dict(data)
66+
sample = DecodeTestSample.from_dict(data)
6767

6868
assert sample.name == "h264_test"
6969
assert sample.codec == CodecType.H264
@@ -74,7 +74,7 @@ def test_from_dict_valid(self):
7474
assert sample.expected_output_md5 == "def456"
7575

7676
def test_from_dict_optional_fields(self):
77-
"""Test creating DecodeSample with missing optional fields"""
77+
"""Test creating DecodeTestSample with missing optional fields"""
7878
data = {
7979
"name": "minimal_test",
8080
"codec": "av1",
@@ -83,7 +83,7 @@ def test_from_dict_optional_fields(self):
8383
"source_filepath": "video/test.ivf",
8484
}
8585

86-
sample = DecodeSample.from_dict(data)
86+
sample = DecodeTestSample.from_dict(data)
8787

8888
assert sample.name == "minimal_test"
8989
assert sample.codec == CodecType.AV1
@@ -102,11 +102,11 @@ def test_from_dict_missing_required_field(self):
102102
}
103103

104104
with pytest.raises(KeyError):
105-
DecodeSample.from_dict(data)
105+
DecodeTestSample.from_dict(data)
106106

107107
def test_display_name_prefix(self):
108108
"""Test that display_name adds decode_ prefix"""
109-
sample = DecodeSample(
109+
sample = DecodeTestSample(
110110
name="h264_test",
111111
codec=CodecType.H264,
112112
source_url="",
@@ -119,12 +119,15 @@ def test_display_name_prefix(self):
119119
def test_display_name_different_codecs(self):
120120
"""Test display_name with different codecs"""
121121
samples = [
122-
DecodeSample(name="test", codec=CodecType.H264, source_url="",
123-
source_checksum="", source_filepath=""),
124-
DecodeSample(name="test", codec=CodecType.H265, source_url="",
125-
source_checksum="", source_filepath=""),
126-
DecodeSample(name="test", codec=CodecType.AV1, source_url="",
127-
source_checksum="", source_filepath=""),
122+
DecodeTestSample(name="test", codec=CodecType.H264,
123+
source_url="", source_checksum="",
124+
source_filepath=""),
125+
DecodeTestSample(name="test", codec=CodecType.H265,
126+
source_url="", source_checksum="",
127+
source_filepath=""),
128+
DecodeTestSample(name="test", codec=CodecType.AV1,
129+
source_url="", source_checksum="",
130+
source_filepath=""),
128131
]
129132

130133
# All should have same display_name regardless of codec

tests/video_test_framework_decode.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
@dataclass(init=False)
6060
# pylint: disable=too-many-instance-attributes
61-
class DecodeSample(BaseTestConfig):
61+
class DecodeTestSample(BaseTestConfig):
6262
"""Configuration for decoder test cases with download capability"""
6363
expected_output_md5: str = "" # Expected MD5 of decoded YUV output
6464

@@ -76,7 +76,7 @@ def __init__(
7676
source_filepath: str = "",
7777
expected_output_md5: str = "",
7878
):
79-
"""Initialize DecodeSample with all fields from base and child"""
79+
"""Initialize DecodeTestSample with all fields from base and child"""
8080
super().__init__(
8181
name=name,
8282
codec=codec,
@@ -91,8 +91,8 @@ def __init__(
9191
self.expected_output_md5 = expected_output_md5
9292

9393
@classmethod
94-
def from_dict(cls, data: dict) -> 'DecodeSample':
95-
"""Create a DecodeSample from a dictionary"""
94+
def from_dict(cls, data: dict) -> 'DecodeTestSample':
95+
"""Create a DecodeTestSample from a dictionary"""
9696
return cls(
9797
name=data["name"],
9898
codec=CodecType(data["codec"]),
@@ -144,14 +144,14 @@ class VulkanVideoDecodeTestFramework(VulkanVideoTestFrameworkBase):
144144

145145
def _load_decode_samples(
146146
self, json_file: str = "decode_samples.json"
147-
) -> List[DecodeSample]:
147+
) -> List[DecodeTestSample]:
148148
"""Load decode samples from JSON configuration"""
149149
samples_data = load_samples_from_json(json_file, test_type="decode")
150150
samples = []
151151

152152
for sample_data in samples_data:
153153
try:
154-
sample = DecodeSample.from_dict(sample_data)
154+
sample = DecodeTestSample.from_dict(sample_data)
155155
samples.append(sample)
156156
except (KeyError, ValueError, TypeError) as e:
157157
msg = (
@@ -182,7 +182,7 @@ def __init__(self, decoder_path: str = None, **options):
182182
f"Decoder not found: {self.executable_path}")
183183

184184
def check_resources(self, auto_download: bool = True,
185-
test_configs: List[DecodeSample] = None) -> bool:
185+
test_configs: List[DecodeTestSample] = None) -> bool:
186186
"""Check if required resource files are available and have correct
187187
checksums
188188
@@ -197,13 +197,13 @@ def check_resources(self, auto_download: bool = True,
197197
"decoder resource",
198198
auto_download)
199199

200-
def _run_decoder_test(self, config: DecodeSample) -> TestResult:
200+
def _run_decoder_test(self, config: DecodeTestSample) -> TestResult:
201201
"""Run decoder test for specified codec"""
202202
if not self.decoder_path:
203203
return create_error_result(config, "Decoder path not specified")
204204

205205
# Use the sample file directly from the config
206-
# (since DecodeSample now contains everything)
206+
# (since DecodeTestSample now contains everything)
207207
input_file = config.full_path
208208

209209
if not input_file.exists():
@@ -269,22 +269,22 @@ def create_test_suite(
269269
self,
270270
codec_filter: Optional[str] = None,
271271
test_pattern: Optional[str] = None,
272-
) -> List[DecodeSample]:
272+
) -> List[DecodeTestSample]:
273273
"""Create test suite from samples with optional filtering"""
274274
# Use base class filtering method with skip list
275275
return self.filter_test_suite(
276276
self.decode_samples, codec_filter, test_pattern,
277277
self.skip_filter, test_format="vvs", test_type="decode"
278278
)
279279

280-
def run_single_test(self, config: DecodeSample) -> TestResult:
280+
def run_single_test(self, config: DecodeTestSample) -> TestResult:
281281
"""Run a single test case - implementation for base class"""
282282
result = self._run_decoder_test(config)
283283
self._validate_test_result(result)
284284
return result
285285

286286
def run_test_suite(
287-
self, test_configs: List[DecodeSample] = None
287+
self, test_configs: List[DecodeTestSample] = None
288288
) -> List[TestResult]:
289289
"""Run complete test suite using base class implementation"""
290290
return self.run_test_suite_base(test_configs, test_type="decode")

0 commit comments

Comments
 (0)