@@ -91,43 +91,36 @@ def test_display_name_for_display_from_benefit(self, mocked_name_for_display):
9191 mocked_name_for_display .assert_called_once_with (package = package )
9292
9393
94- class IdealSizeTemplateTagTests (TestCase ):
94+ def test_ideal_size_handles_missing_file_association (self ):
95+ class MockImageWithoutFile :
96+ def __bool__ (self ):
97+ return False
98+
99+ size = ideal_size (MockImageWithoutFile (), 250 )
100+ # Should return ideal_dimension directly as fallback
101+ self .assertEqual (size , 250 )
102+
95103 def test_ideal_size_scales_properly (self ):
96104 class MockImage :
97105 width = 400
98106 height = 200
99107
108+ def __bool__ (self ):
109+ return True
110+
100111 size = ideal_size (MockImage (), 200 )
101112 # int(400 * sqrt(20000 / 80000)) = int(400 * 0.5) = 200
102113 self .assertEqual (size , 200 )
103114
104115 def test_ideal_size_handles_file_not_found (self ):
105- class MockImageWithoutFile :
116+ class MockImageWithMissingFileOnDisk :
106117 @property
107118 def width (self ):
108119 raise FileNotFoundError
109120
110- size = ideal_size (MockImageWithoutFile (), 300 )
111- # Should return ideal_dimension directly as fallback
112- self .assertEqual (size , 300 )
113-
114- def test_ideal_size_handles_value_error (self ):
115- class MockImageWithoutFileValue :
116- @property
117- def width (self ):
118- msg = "The 'web_logo' attribute has no file associated with it."
119- raise ValueError (msg )
121+ def __bool__ (self ):
122+ return True
120123
121- size = ideal_size (MockImageWithoutFileValue (), 250 )
124+ size = ideal_size (MockImageWithMissingFileOnDisk (), 300 )
122125 # Should return ideal_dimension directly as fallback
123- self .assertEqual (size , 250 )
124-
125- def test_ideal_size_raises_other_value_errors (self ):
126- class MockImageWithOtherValueError :
127- @property
128- def width (self ):
129- msg = "Other error"
130- raise ValueError (msg )
131-
132- with self .assertRaises (ValueError ):
133- ideal_size (MockImageWithOtherValueError (), 250 )
126+ self .assertEqual (size , 300 )
0 commit comments