Skip to content

Commit dad0c3e

Browse files
committed
Drop airport list pagination guard
1 parent 546b103 commit dad0c3e

2 files changed

Lines changed: 0 additions & 51 deletions

File tree

app/routers/airport.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,6 @@ def get_airports_list(
7979
db=Depends(CouchbaseClient),
8080
) -> list[Airport]:
8181
"""Get a list of airports with pagination. Optionally, filter by country."""
82-
completeness_filters = """
83-
airport.airportname IS NOT MISSING
84-
AND airport.airportname IS NOT NULL
85-
AND airport.city IS NOT MISSING
86-
AND airport.city IS NOT NULL
87-
AND airport.country IS NOT MISSING
88-
AND airport.country IS NOT NULL
89-
"""
90-
9182
if country:
9283
query = """
9384
SELECT airport.airportname,
@@ -99,7 +90,6 @@ def get_airports_list(
9990
airport.tz
10091
FROM airport AS airport
10192
WHERE airport.country = $country
102-
AND """ + completeness_filters + """
10393
ORDER BY airport.airportname
10494
LIMIT $limit
10595
OFFSET $offset;
@@ -114,7 +104,6 @@ def get_airports_list(
114104
airport.icao,
115105
airport.tz
116106
FROM airport AS airport
117-
WHERE """ + completeness_filters + """
118107
ORDER BY airport.airportname
119108
LIMIT $limit
120109
OFFSET $offset;

app/tests/test_airport.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,10 @@
33
from couchbase.exceptions import DocumentNotFoundException
44

55
from app.main import app
6-
from app.routers.airport import get_airports_list
76

87
client = TestClient(app)
98

109

11-
class RecordingDB:
12-
def __init__(self, rows):
13-
self.rows = rows
14-
self.calls = []
15-
16-
def query(self, query, **params):
17-
self.calls.append((query, params))
18-
return self.rows
19-
20-
21-
def test_list_airports_bakes_required_fields_into_the_query_before_pagination():
22-
db = RecordingDB([])
23-
24-
assert get_airports_list(limit=3, offset=6, db=db) == []
25-
26-
query, params = db.calls[0]
27-
assert "airport.airportname IS NOT MISSING" in query
28-
assert "airport.airportname IS NOT NULL" in query
29-
assert "airport.city IS NOT MISSING" in query
30-
assert "airport.city IS NOT NULL" in query
31-
assert "airport.country IS NOT MISSING" in query
32-
assert "airport.country IS NOT NULL" in query
33-
assert "ORDER BY airport.airportname" in query
34-
assert "LIMIT $limit" in query
35-
assert "OFFSET $offset" in query
36-
assert params == {"country": None, "limit": 3, "offset": 6}
37-
38-
39-
def test_list_airports_bakes_country_filter_into_the_query_when_present():
40-
db = RecordingDB([])
41-
42-
assert get_airports_list(country="France", limit=2, offset=4, db=db) == []
43-
44-
query, params = db.calls[0]
45-
assert "WHERE airport.country = $country" in query
46-
assert "airport.airportname IS NOT MISSING" in query
47-
assert params == {"country": "France", "limit": 2, "offset": 4}
48-
49-
5010
class TestAirport:
5111
def test_add_airport(
5212
self, couchbase_client, airport_api, airport_collection, helpers

0 commit comments

Comments
 (0)