Field Assertions¶
Field assertion helpers for test validation.
- class tests.helpers.field_assertions.FieldAssertions[source]¶
Bases:
objectMixin class providing field validation assertion methods.
- assert_bool_field(data, field, index=None)[source]¶
Assert that a field value is a boolean.
- Parameters:
data – Dictionary containing the field to validate.
field – Name of the field to check.
index – Optional array index for contextual error messages.
- Raises:
AssertionError – If the field is not a boolean.
- assert_float_field(data, field, index=None)[source]¶
Assert that a field value is a positive float.
For ‘vote_average’ fields, validates range is 0.0-10.0.
- Parameters:
data – Dictionary containing the field to validate.
field – Name of the field to check.
index – Optional array index for contextual error messages.
- Raises:
AssertionError – If the field is not a float or out of range.
- assert_int_field(data, field, index=None, id_val=None)[source]¶
Assert that a field value is a positive integer.
- Parameters:
data – Dictionary containing the field to validate.
field – Name of the field to check.
index – Optional array index for contextual error messages.
id_val – Optional expected value for ‘id’ fields.
- Raises:
AssertionError – If the field is not an integer or not positive.
- assert_list_field(data, field, index=None)[source]¶
Assert that a field value is a non-empty list.
- Parameters:
data – Dictionary containing the field to validate.
field – Name of the field to check.
index – Optional array index for contextual error messages.
- Raises:
AssertionError – If the field is not a list or is empty.
- assert_path_field(data, field, index=None)[source]¶
Assert that a field is a valid image path or null.
Validates that the path ends with ‘.png’ or ‘.jpg’ if not null.
- Parameters:
data – Dictionary containing the field to validate.
field – Name of the field to check.
index – Optional array index for contextual error messages.
- Raises:
AssertionError – If field is missing or has invalid format.
- assert_str_field(data, field, index=None)[source]¶
Assert that a field value is a non-empty string.
For ‘original_language’ fields, validates 2-character ISO code length.
- Parameters:
data – Dictionary containing the field to validate.
field – Name of the field to check.
index – Optional array index for contextual error messages.
- Raises:
AssertionError – If the field is not a string or is empty.