99from PIL import Image , UnidentifiedImageError
1010
1111import sys
12+
1213sys .path .append (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
1314
1415from data_fetcher import DataFetcher
@@ -30,10 +31,10 @@ def test_fetch_json_success(self, mock_get):
3031 mock_get .return_value = mock_response
3132
3233 # Test
33- result = self .fetcher .fetch_json ("http ://example.com/api" )
34+ result = self .fetcher .fetch_json ("https ://example.com/api" )
3435
3536 # Verify
36- mock_get .assert_called_once_with ("http ://example.com/api" , timeout = 5 )
37+ mock_get .assert_called_once_with ("https ://example.com/api" , timeout = 5 )
3738 mock_response .raise_for_status .assert_called_once ()
3839 self .assertEqual (result , {"key" : "value" })
3940
@@ -45,7 +46,7 @@ def test_fetch_json_error(self, mock_get):
4546
4647 # Test
4748 with self .assertRaises (requests .RequestException ):
48- self .fetcher .fetch_json ("http ://example.com/api" )
49+ self .fetcher .fetch_json ("https ://example.com/api" )
4950
5051 @patch ('requests.get' )
5152 @patch ('PIL.Image.open' )
@@ -62,10 +63,11 @@ def test_fetch_image_success(self, mock_open, mock_get):
6263 mock_open .return_value = mock_image
6364
6465 # Test
65- result = self .fetcher .fetch_image ("http ://example.com/image.jpg" )
66+ result = self .fetcher .fetch_image ("https ://example.com/image.jpg" )
6667
6768 # Verify
68- mock_get .assert_called_once_with ("http://example.com/image.jpg" , timeout = 5 )
69+ mock_get .assert_called_once_with ("https://example.com/image.jpg" ,
70+ timeout = 5 )
6971 mock_response .raise_for_status .assert_called_once ()
7072 mock_image .convert .assert_called_once_with ("RGBA" )
7173 self .assertEqual (result , mock_image )
@@ -78,7 +80,7 @@ def test_fetch_image_request_error(self, mock_get):
7880
7981 # Test
8082 with self .assertRaises (requests .RequestException ):
81- self .fetcher .fetch_image ("http ://example.com/image.jpg" )
83+ self .fetcher .fetch_image ("https ://example.com/image.jpg" )
8284
8385 @patch ('requests.get' )
8486 @patch ('PIL.Image.open' )
@@ -94,7 +96,7 @@ def test_fetch_image_processing_error(self, mock_open, mock_get):
9496
9597 # Test
9698 with self .assertRaises (IOError ):
97- self .fetcher .fetch_image ("http ://example.com/image.jpg" )
99+ self .fetcher .fetch_image ("https ://example.com/image.jpg" )
98100
99101 @patch ('PIL.Image.open' )
100102 def test_load_local_image_success (self , mock_open ):
@@ -142,10 +144,10 @@ def test_fetch_speakers(self, mock_fetch_json):
142144 ]
143145
144146 # Test
145- result = self .fetcher .fetch_speakers ("http ://example.com/speakers" )
147+ result = self .fetcher .fetch_speakers ("https ://example.com/speakers" )
146148
147149 # Verify
148- mock_fetch_json .assert_called_once_with ("http ://example.com/speakers" )
150+ mock_fetch_json .assert_called_once_with ("https ://example.com/speakers" )
149151 self .assertEqual (result , {
150152 "1" : {"id" : "1" , "name" : "Speaker 1" },
151153 "2" : {"id" : "2" , "name" : "Speaker 2" }
@@ -172,10 +174,11 @@ def test_fetch_sessions_by_track(self, mock_fetch_json):
172174 ]
173175
174176 # Test
175- result = self .fetcher .fetch_sessions_by_track ("http://example.com/sessions" )
177+ result = self .fetcher .fetch_sessions_by_track (
178+ "https://example.com/sessions" )
176179
177180 # Verify
178- mock_fetch_json .assert_called_once_with ("http ://example.com/sessions" )
181+ mock_fetch_json .assert_called_once_with ("https ://example.com/sessions" )
179182 self .assertEqual (result , {
180183 "Track 1" : [
181184 {"id" : "1" , "title" : "Session 1" },
@@ -193,10 +196,11 @@ def test_fetch_sessions_by_track_empty(self, mock_fetch_json):
193196 mock_fetch_json .return_value = []
194197
195198 # Test
196- result = self .fetcher .fetch_sessions_by_track ("http://example.com/sessions" )
199+ result = self .fetcher .fetch_sessions_by_track (
200+ "https://example.com/sessions" )
197201
198202 # Verify
199- mock_fetch_json .assert_called_once_with ("http ://example.com/sessions" )
203+ mock_fetch_json .assert_called_once_with ("https ://example.com/sessions" )
200204 self .assertEqual (result , {})
201205
202206
0 commit comments