Skip to content

Commit b424f46

Browse files
committed
Adding Mock Data to test cases
1 parent 2e93623 commit b424f46

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

search/tests.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ def test_photo(self):
118118
"""
119119
Tests that a specific photo is retrieved
120120
"""
121-
photo_link = FourSquarePlacesHelper().get_place_photo(fsq_id="518a71ab498e430858000827")
122-
site = urlopen(photo_link)
123-
meta = site.info()
124-
if meta["content-type"] in image_formats:
125-
assert True
121+
with patch('info.helpers.places.FourSquarePlacesHelper.get_place_photo') as mock_get_place_photo:
122+
mock_get_place_photo.return_value = "https://example.com/photo.jpg"
123+
photo_link = FourSquarePlacesHelper().get_place_photo(city="Pune")
124+
assert photo_link is not None
125+
126126

127127
# This test works, however due to the limit on weather API key usage it is commented out
128128
# def test_weather_info(self):
@@ -195,13 +195,15 @@ def test_arts_info(self, mock_get_places):
195195
assert len(art_info) == 2
196196
assert art_info[0]["name"] == "Arts A"
197197

198-
def test_city_photo(self):
198+
@patch('search.helpers.photo.UnplashCityPhotoHelper.get_city_photo')
199+
def test_city_photo(self,mock_get_city_photo):
199200
"""
200201
Tests that a city photo can be retrieved for New York City.
201202
"""
202203
city = "New York City"
204+
mock_get_city_photo.return_value = "https://example.com/photo.jpg"
203205
photo_link = UnplashCityPhotoHelper().get_city_photo(city=city)
204-
assert photo_link is not None # Ensure we got a photo link
206+
assert photo_link is not None
205207

206208
def test_models(self):
207209
"""

0 commit comments

Comments
 (0)