Skip to content

Commit 0e2c530

Browse files
committed
Allow missing layers in arcgis lambda again, now we have tested lambda exception handling
1 parent 79ee393 commit 0e2c530

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

backend/lambda_functions/arcgis_loader/arcgis_loader.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,12 @@ def get_features(self) -> FeatureCollection: # type: ignore[override]
172172
for layer in layer_list
173173
if layer["name"] == layer_name
174174
]
175-
# TODO: commented to cause exception in case of missing layers
176-
# if not layer_ids:
177-
# LOGGER.warn(
178-
# f"Layer {layer_name} not found in source. Skipping "
179-
# "this layer."
180-
# )
181-
# continue
175+
if not layer_ids:
176+
LOGGER.warn(
177+
f"Layer {layer_name} not found in source. Skipping "
178+
"this layer."
179+
)
180+
continue
182181
layer_id = layer_ids[0]
183182
LOGGER.debug(f"Querying layer {layer_name}...")
184183
r = requests.get(

backend/lambda_functions/base_loader/base_loader.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import json
44
import logging
55
import os
6-
7-
# import sys
8-
# import traceback
96
from typing import Any, Dict, List, Optional, Type, TypedDict, Union
107

118
import boto3

backend/test/test_services.py

+21-22
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,24 @@ def test_populate_wfs(populate_wfs_layers, main_db_params):
184184
conn.close()
185185

186186

187-
# TODO: disabled for testing
188-
# def test_populate_arcgis(populate_closest_data_to_arcgis_layers, main_db_params):
189-
# conn = psycopg2.connect(**main_db_params)
190-
# try:
191-
# with conn.cursor() as cur:
192-
# print(ArcGisLoader.TABLE_NAMES)
193-
# for metadata_table, data_tables in ArcGisLoader.TABLE_NAMES.items():
194-
# for table_name in data_tables.values():
195-
# print(table_name)
196-
# cur.execute(f"SELECT count(*) FROM kooste.{table_name}")
197-
# count = cur.fetchone()[0]
198-
199-
# # Temporarily disable layer size check, as long as
200-
# # SYKE arcrest API is unreliable
201-
# # assert count > 0
202-
203-
# # Whenever arcgis parameters are slightly wrong, it just
204-
# # returns *all* the data. Way to design an API with such
205-
# # a baseload. Check that we don't get all 40 000 geometries
206-
# assert count < 1000
207-
# finally:
208-
# conn.close()
187+
def test_populate_arcgis(populate_closest_data_to_arcgis_layers, main_db_params):
188+
conn = psycopg2.connect(**main_db_params)
189+
try:
190+
with conn.cursor() as cur:
191+
print(ArcGisLoader.TABLE_NAMES)
192+
for metadata_table, data_tables in ArcGisLoader.TABLE_NAMES.items():
193+
for table_name in data_tables.values():
194+
print(table_name)
195+
cur.execute(f"SELECT count(*) FROM kooste.{table_name}")
196+
count = cur.fetchone()[0]
197+
198+
# Temporarily disable layer size check, as long as
199+
# SYKE arcrest API is unreliable
200+
# assert count > 0
201+
202+
# Whenever arcgis parameters are slightly wrong, it just
203+
# returns *all* the data. Way to design an API with such
204+
# a baseload. Check that we don't get all 40 000 geometries
205+
assert count < 1000
206+
finally:
207+
conn.close()

0 commit comments

Comments
 (0)