Skip to content

Commit

Permalink
make tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Jul 21, 2024
1 parent dc693d7 commit 2ec1fd4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions api/openrailwaymap_api/facility_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import HTTPException
from starlette.status import HTTP_400_BAD_REQUEST

from api import MAX_LIMIT
# from api import MAX_LIMIT

QUERY_PARAMETERS = ['q', 'name', 'ref', 'uic_ref']

Expand Down Expand Up @@ -46,11 +46,11 @@ async def __call__(self, *, q, name, ref, uic_ref, limit):
HTTP_400_BAD_REQUEST,
{'type': 'limit_not_integer', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'The provided limit cannot be parsed as an integer value.'}
)
if self.limit > MAX_LIMIT:
raise HTTPException(
HTTP_400_BAD_REQUEST,
{'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'}
)
# if self.limit > MAX_LIMIT:
# raise HTTPException(
# HTTP_400_BAD_REQUEST,
# {'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'}
# )
if name:
return await self.search_by_name(name)
if ref:
Expand Down Expand Up @@ -88,7 +88,7 @@ async def search_by_name(self, q):
) AS a
) AS b
ORDER BY rank DESC NULLS LAST
LIMIT %2;"""
LIMIT $2;"""

async with self.database.acquire() as connection:
statement = await connection.prepare(sql_query)
Expand All @@ -104,8 +104,8 @@ async def _search_by_ref(self, search_key, ref):
sql_query = f"""SELECT DISTINCT ON (osm_id)
{fields}, ST_X(ST_Transform(geom, 4326)) AS latitude, ST_Y(ST_Transform(geom, 4326)) AS longitude
FROM openrailwaymap_ref
WHERE {search_key} = %s
LIMIT %s;"""
WHERE {search_key} = $1
LIMIT $2;"""

async with self.database.acquire() as connection:
statement = await connection.prepare(sql_query)
Expand Down
10 changes: 5 additions & 5 deletions api/openrailwaymap_api/milestone_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ async def __call__(self, *, ref, position, limit):
HTTP_400_BAD_REQUEST,
{'type': 'limit_not_integer', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'The provided limit cannot be parsed as an integer value.'}
)
if limit > self.MAX_LIMIT:
raise HTTPException(
HTTP_400_BAD_REQUEST,
{'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'}
)
# if limit > self.MAX_LIMIT:
# raise HTTPException(
# HTTP_400_BAD_REQUEST,
# {'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'}
# )
self.data = await self.get_milestones(position, ref, limit)
return self.data

Expand Down

0 comments on commit 2ec1fd4

Please sign in to comment.