Skip to content

Commit

Permalink
Allow missing layers in arcgis lambda again, now we have tested lambd…
Browse files Browse the repository at this point in the history
…a exception handling
  • Loading branch information
Rikuoja committed Nov 29, 2023
1 parent 79ee393 commit 0e2c530
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 32 deletions.
13 changes: 6 additions & 7 deletions backend/lambda_functions/arcgis_loader/arcgis_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,12 @@ def get_features(self) -> FeatureCollection: # type: ignore[override]
for layer in layer_list
if layer["name"] == layer_name
]
# TODO: commented to cause exception in case of missing layers
# if not layer_ids:
# LOGGER.warn(
# f"Layer {layer_name} not found in source. Skipping "
# "this layer."
# )
# continue
if not layer_ids:
LOGGER.warn(
f"Layer {layer_name} not found in source. Skipping "
"this layer."
)
continue
layer_id = layer_ids[0]
LOGGER.debug(f"Querying layer {layer_name}...")
r = requests.get(
Expand Down
3 changes: 0 additions & 3 deletions backend/lambda_functions/base_loader/base_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import json
import logging
import os

# import sys
# import traceback
from typing import Any, Dict, List, Optional, Type, TypedDict, Union

import boto3
Expand Down
43 changes: 21 additions & 22 deletions backend/test/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,25 +184,24 @@ def test_populate_wfs(populate_wfs_layers, main_db_params):
conn.close()


# TODO: disabled for testing
# def test_populate_arcgis(populate_closest_data_to_arcgis_layers, main_db_params):
# conn = psycopg2.connect(**main_db_params)
# try:
# with conn.cursor() as cur:
# print(ArcGisLoader.TABLE_NAMES)
# for metadata_table, data_tables in ArcGisLoader.TABLE_NAMES.items():
# for table_name in data_tables.values():
# print(table_name)
# cur.execute(f"SELECT count(*) FROM kooste.{table_name}")
# count = cur.fetchone()[0]

# # Temporarily disable layer size check, as long as
# # SYKE arcrest API is unreliable
# # assert count > 0

# # Whenever arcgis parameters are slightly wrong, it just
# # returns *all* the data. Way to design an API with such
# # a baseload. Check that we don't get all 40 000 geometries
# assert count < 1000
# finally:
# conn.close()
def test_populate_arcgis(populate_closest_data_to_arcgis_layers, main_db_params):
conn = psycopg2.connect(**main_db_params)
try:
with conn.cursor() as cur:
print(ArcGisLoader.TABLE_NAMES)
for metadata_table, data_tables in ArcGisLoader.TABLE_NAMES.items():
for table_name in data_tables.values():
print(table_name)
cur.execute(f"SELECT count(*) FROM kooste.{table_name}")
count = cur.fetchone()[0]

# Temporarily disable layer size check, as long as
# SYKE arcrest API is unreliable
# assert count > 0

# Whenever arcgis parameters are slightly wrong, it just
# returns *all* the data. Way to design an API with such
# a baseload. Check that we don't get all 40 000 geometries
assert count < 1000
finally:
conn.close()

0 comments on commit 0e2c530

Please sign in to comment.