Skip to content

Commit c0599af

Browse files
committed
[Fixes #13826] updated older test cases and formated the code
1 parent 89ae02d commit c0599af

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

geonode/thumbs/tests/test_unit.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def test_datasets_locations_dataset(self):
201201
locations, bbox = thumbnails._datasets_locations(dataset)
202202

203203
self.assertFalse(bbox, "Expected BBOX not to be calculated")
204-
self.assertEqual(locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], []]])
204+
self.assertEqual(locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], [], {}]])
205205

206206
def test_datasets_locations_dataset_default_bbox(self):
207207
expected_bbox = [-8238681.374829309, -8220320.783295829, 4969844.0930337105, 4984363.884452854, "EPSG:3857"]
@@ -211,7 +211,7 @@ def test_datasets_locations_dataset_default_bbox(self):
211211

212212
self.assertEqual(bbox[-1].upper(), "EPSG:3857", "Expected calculated BBOX CRS to be EPSG:3857")
213213
self.assertEqual(bbox, expected_bbox, "Expected calculated BBOX to match pre-converted one.")
214-
self.assertEqual(locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], []]])
214+
self.assertEqual(locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], [], {}]])
215215

216216
def test_datasets_locations_dataset_bbox(self):
217217
dataset = Dataset.objects.get(title="theaters_nyc")
@@ -222,7 +222,7 @@ def test_datasets_locations_dataset_bbox(self):
222222
self.assertEqual(
223223
bbox[-1].lower(), dataset.bbox[-1].lower(), "Expected calculated BBOX's CRS to match dataset's"
224224
)
225-
self.assertEqual(locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], []]])
225+
self.assertEqual(locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], [], {}]])
226226

227227
def test_datasets_locations_simple_map(self):
228228
dataset = Dataset.objects.get(title="theaters_nyc")
@@ -243,6 +243,7 @@ def test_datasets_locations_simple_map(self):
243243
settings.OGC_SERVER["default"]["LOCATION"],
244244
[dataset.alternate, "geonode:Meteorite_Landings_from_NASA_Open_Data_Portal1"],
245245
["theaters_nyc", "test_style"],
246+
{},
246247
]
247248
],
248249
)
@@ -258,7 +259,7 @@ def test_datasets_locations_simple_map_default_bbox(self):
258259
self.assertEqual(bbox[-1].upper(), "EPSG:3857", "Expected calculated BBOX CRS to be EPSG:3857")
259260
self.assertEqual(bbox, expected_bbox, "Expected calculated BBOX to match pre-converted one.")
260261
self.assertEqual(
261-
locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], ["theaters_nyc"]]]
262+
locations, [[settings.OGC_SERVER["default"]["LOCATION"], [dataset.alternate], ["theaters_nyc"], {}]]
262263
)
263264

264265
def test_datasets_locations_composition_map_default_bbox(self):
@@ -271,6 +272,7 @@ def test_datasets_locations_composition_map_default_bbox(self):
271272
"rt_geologia.dbg_risorse_minerarie",
272273
],
273274
[],
275+
{},
274276
]
275277
]
276278

geonode/thumbs/thumbnails.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ def _datasets_locations(
275275
auth_info = {}
276276
if instance.remote_service and instance.remote_service.needs_authentication:
277277
auth_info = {
278-
'username': instance.remote_service.username,
279-
'password': instance.remote_service.get_password()
278+
"username": instance.remote_service.username,
279+
"password": instance.remote_service.get_password(),
280280
}
281281
locations.append([instance.ows_url or ogc_server_settings.LOCATION, [instance.alternate], [], auth_info])
282282
if compute_bbox:
@@ -320,8 +320,8 @@ def _datasets_locations(
320320
auth_info = {}
321321
if dataset.remote_service and dataset.remote_service.needs_authentication:
322322
auth_info = {
323-
'username': dataset.remote_service.username,
324-
'password': dataset.remote_service.get_password()
323+
"username": dataset.remote_service.username,
324+
"password": dataset.remote_service.get_password(),
325325
}
326326
# limit number of locations, ensuring dataset order
327327
if len(locations) and locations[-1][0] == dataset.remote_service.service_url:

geonode/thumbs/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def get_map(
204204
headers["Authorization"] = f"Bearer {additional_kwargs['access_token']}"
205205

206206
# Check if auth_info is provided (for remote services with authentication)
207-
if auth_info and auth_info.get('username') and auth_info.get('password'):
207+
if auth_info and auth_info.get("username") and auth_info.get("password"):
208208
# Use provided authentication credentials for remote service
209209
encoded_credentials = base64.b64encode(
210210
f"{auth_info['username']}:{auth_info['password']}".encode("UTF-8")

0 commit comments

Comments
 (0)