Skip to content
Open
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
2 changes: 1 addition & 1 deletion pictures/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def _check_aspect_ratios(self):
return errors

def _check_width_height_field(self):
if None in self.aspect_ratios and not (self.width_field and self.height_field):
if not (self.width_field and self.height_field):
return [
checks.Warning(
"width_field and height_field attributes are missing",
Expand Down
16 changes: 13 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,19 @@ def test_check_aspect_ratios(self):
assert errors
assert errors[0].id == "fields.E100"

def test_check_width_height_field(self):
assert not PictureField(aspect_ratios=["3/2"])._check_width_height_field()
with override_field_aspect_ratios(Profile.picture.field, [None]):
@pytest.mark.parametrize(
"aspect_ratios",
[
("3/2",),
(None,),
(
"3/2",
None,
),
],
)
def test_check_width_height_field(self, aspect_ratios):
with override_field_aspect_ratios(Profile.picture.field, aspect_ratios):
errors = Profile.picture.field._check_width_height_field()
assert errors
assert errors[0].id == "fields.E101"
Expand Down