@@ -109,11 +109,10 @@ def test_cityphoto(self):
109
109
"""
110
110
Tests that an image is returned after getting a city
111
111
"""
112
- photo_link = UnplashCityPhotoHelper ().get_city_photo (city = "Pune" )
113
- site = urlopen (photo_link )
114
- meta = site .info ()
115
- if meta ["content-type" ] in image_formats :
116
- assert True
112
+ with patch ('search.helpers.photo.UnplashCityPhotoHelper.get_city_photo' ) as mock_get_city_photo :
113
+ mock_get_city_photo .return_value = "https://example.com/photo.jpg"
114
+ photo_link = UnplashCityPhotoHelper ().get_city_photo (city = "Pune" )
115
+ assert photo_link is not None
117
116
118
117
def test_photo (self ):
119
118
"""
@@ -153,17 +152,15 @@ def test_photo(self):
153
152
# except Exception:
154
153
# self.fail("Weather API call failed or returned no data.")
155
154
156
- def test_dining_info (self ):
157
- """
158
- Tests that dining information can be retrieved
159
- """
160
- city = "New York City"
161
- country = "US"
162
-
163
- dining_info = FourSquarePlacesHelper ().get_places (
164
- city = f"{ city } , { country } " , categories = "13065" , sort = "RELEVANCE" , limit = 5
165
- )
166
- assert dining_info is not None and len (dining_info ) > 0 # Ensure we got dining info
155
+ @patch ('info.helpers.places.FourSquarePlacesHelper.get_places' )
156
+ def test_dining_info (self , mock_get_places ):
157
+ mock_get_places .return_value = [
158
+ {"name" : "Restaurant A" , "address" : "Address A" },
159
+ {"name" : "Restaurant B" , "address" : "Address B" },
160
+ ]
161
+ dining_info = FourSquarePlacesHelper ().get_places (city = "New York" , categories = "13065" , limit = 5 )
162
+ assert len (dining_info ) == 2
163
+ assert dining_info [0 ]["name" ] == "Restaurant A"
167
164
168
165
def test_outdoor_info (self ):
169
166
"""
0 commit comments