Skip to content

Commit 9d420bb

Browse files
committed
fix async issue
1 parent ebb1d09 commit 9d420bb

3 files changed

Lines changed: 36 additions & 40 deletions

File tree

functions-python/operations_api/src/feeds_operations/impl/feeds_operations_impl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def handle_get_feeds(
174174
status_code=500, detail=f"Internal server error: {str(e)}"
175175
)
176176

177-
async def get_feeds(
177+
def get_feeds(
178178
self,
179179
search_query: Optional[str] = None,
180180
operation_status: Optional[str] = None,
@@ -189,7 +189,7 @@ async def get_feeds(
189189
)
190190

191191
@with_db_session
192-
async def get_gtfs_feed(
192+
def get_gtfs_feed(
193193
self,
194194
id: Annotated[
195195
StrictStr, Field(description="The feed ID of the requested feed.")
@@ -205,7 +205,7 @@ async def get_gtfs_feed(
205205
return OperationGtfsFeedImpl.from_orm(gtfs_feed)
206206

207207
@with_db_session
208-
async def get_gtfs_feed_availability(
208+
def get_gtfs_feed_availability(
209209
self,
210210
id: Annotated[
211211
StrictStr, Field(description="The feed ID of the requested feed.")
@@ -249,7 +249,7 @@ async def get_gtfs_feed_availability(
249249
)
250250

251251
@with_db_session
252-
async def get_gtfs_rt_feed(
252+
def get_gtfs_rt_feed(
253253
self,
254254
id: Annotated[
255255
StrictStr, Field(description="The feed ID of the requested feed.")

functions-python/operations_api/tests/feeds_operations/impl/test_availability_operations_impl.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
async def test_get_gtfs_feed_availability_basic():
1515
"""Returns all availability checks for a known feed."""
1616
api = OperationsApiImpl()
17-
response: GtfsFeedAvailabilityResponse = await api.get_gtfs_feed_availability(
17+
response: GtfsFeedAvailabilityResponse = api.get_gtfs_feed_availability(
1818
id=feed_mdb_40.stable_id, var_from=None, to=None, limit=100, offset=0
1919
)
2020
assert response.feed_id == feed_mdb_40.stable_id
@@ -28,7 +28,7 @@ async def test_get_gtfs_feed_availability_basic():
2828
async def test_get_gtfs_feed_availability_ordered_desc_by_default():
2929
"""Results are ordered from newest to oldest by default."""
3030
api = OperationsApiImpl()
31-
response = await api.get_gtfs_feed_availability(
31+
response = api.get_gtfs_feed_availability(
3232
id=feed_mdb_40.stable_id,
3333
var_from=None,
3434
to=None,
@@ -44,7 +44,7 @@ async def test_get_gtfs_feed_availability_ordered_desc_by_default():
4444
async def test_get_gtfs_feed_availability_ordered_asc():
4545
"""sort=asc returns results from oldest to newest."""
4646
api = OperationsApiImpl()
47-
response = await api.get_gtfs_feed_availability(
47+
response = api.get_gtfs_feed_availability(
4848
id=feed_mdb_40.stable_id,
4949
var_from=None,
5050
to=None,
@@ -61,7 +61,7 @@ async def test_get_gtfs_feed_availability_filter_from():
6161
"""Filters checks to those at or after the given from timestamp."""
6262
api = OperationsApiImpl()
6363
from_dt = datetime(2025, 3, 1, tzinfo=timezone.utc)
64-
response = await api.get_gtfs_feed_availability(
64+
response = api.get_gtfs_feed_availability(
6565
id=feed_mdb_40.stable_id, var_from=from_dt, to=None, limit=100, offset=0
6666
)
6767
# Checks on Jan 15 and Feb 10 are excluded; Mar 5, Apr 20, May 1 remain
@@ -74,7 +74,7 @@ async def test_get_gtfs_feed_availability_filter_to():
7474
"""Filters checks to those at or before the given to timestamp."""
7575
api = OperationsApiImpl()
7676
to_dt = datetime(2025, 3, 31, tzinfo=timezone.utc)
77-
response = await api.get_gtfs_feed_availability(
77+
response = api.get_gtfs_feed_availability(
7878
id=feed_mdb_40.stable_id, var_from=None, to=to_dt, limit=100, offset=0
7979
)
8080
# Jan 15, Feb 10, Mar 5 match; Apr 20 and May 1 are excluded
@@ -88,7 +88,7 @@ async def test_get_gtfs_feed_availability_filter_from_to():
8888
api = OperationsApiImpl()
8989
from_dt = datetime(2025, 2, 1, tzinfo=timezone.utc)
9090
to_dt = datetime(2025, 4, 1, tzinfo=timezone.utc)
91-
response = await api.get_gtfs_feed_availability(
91+
response = api.get_gtfs_feed_availability(
9292
id=feed_mdb_40.stable_id, var_from=from_dt, to=to_dt, limit=100, offset=0
9393
)
9494
# Feb 10 and Mar 5 match; Jan 15, Apr 20, May 1 are excluded
@@ -99,7 +99,7 @@ async def test_get_gtfs_feed_availability_filter_from_to():
9999
async def test_get_gtfs_feed_availability_pagination():
100100
"""Pagination respects limit and offset; total is always the full count."""
101101
api = OperationsApiImpl()
102-
response = await api.get_gtfs_feed_availability(
102+
response = api.get_gtfs_feed_availability(
103103
id=feed_mdb_40.stable_id, var_from=None, to=None, limit=2, offset=1
104104
)
105105
assert response.total == len(availability_checks_mdb_40)
@@ -113,7 +113,7 @@ async def test_get_gtfs_feed_availability_not_found():
113113
"""Returns 404 for an unknown feed ID."""
114114
api = OperationsApiImpl()
115115
with pytest.raises(HTTPException) as exc_info:
116-
await api.get_gtfs_feed_availability(
116+
api.get_gtfs_feed_availability(
117117
id="mdb-9999", var_from=None, to=None, limit=100, offset=0
118118
)
119119
assert exc_info.value.status_code == 404
@@ -123,7 +123,7 @@ async def test_get_gtfs_feed_availability_not_found():
123123
async def test_get_gtfs_feed_availability_request_method_mapping():
124124
"""http_head maps to HEAD and http_get maps to GET."""
125125
api = OperationsApiImpl()
126-
response = await api.get_gtfs_feed_availability(
126+
response = api.get_gtfs_feed_availability(
127127
id=feed_mdb_40.stable_id, var_from=None, to=None, limit=100, offset=0
128128
)
129129
methods = {c.request_method for c in response.checks}
@@ -134,7 +134,7 @@ async def test_get_gtfs_feed_availability_request_method_mapping():
134134
async def test_get_gtfs_feed_availability_latency_is_float():
135135
"""latency_ms is returned as float, None when not set."""
136136
api = OperationsApiImpl()
137-
response = await api.get_gtfs_feed_availability(
137+
response = api.get_gtfs_feed_availability(
138138
id=feed_mdb_40.stable_id, var_from=None, to=None, limit=100, offset=0
139139
)
140140
for check in response.checks:

functions-python/operations_api/tests/feeds_operations/impl/test_get_feeds.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def test_get_feeds_no_filters():
2828
"""
2929
api = OperationsApiImpl()
3030

31-
response = await api.get_feeds()
31+
response = api.get_feeds()
3232

3333
assert response is not None
3434
assert response.total == 3
@@ -49,7 +49,7 @@ async def test_get_feeds_gtfs_rt_filter():
4949
"""
5050
api = OperationsApiImpl()
5151

52-
response = await api.get_feeds(data_type="gtfs_rt")
52+
response = api.get_feeds(data_type="gtfs_rt")
5353

5454
assert response is not None
5555
assert response.total == 1
@@ -68,7 +68,7 @@ async def test_get_feeds_gtfs_filter():
6868
"""
6969
api = OperationsApiImpl()
7070

71-
response = await api.get_feeds(data_type="gtfs")
71+
response = api.get_feeds(data_type="gtfs")
7272

7373
assert response is not None
7474
assert response.total == 2
@@ -86,27 +86,27 @@ async def test_get_feeds_pagination():
8686
"""
8787
api = OperationsApiImpl()
8888

89-
response = await api.get_feeds(limit=1)
89+
response = api.get_feeds(limit=1)
9090
assert response.total == 3
9191
assert response.limit == 1
9292
assert response.offset == 0
9393
assert len(response.feeds) == 1
9494
first_feed = response.feeds[0]
9595

96-
response = await api.get_feeds(offset=1, limit=1)
96+
response = api.get_feeds(offset=1, limit=1)
9797
assert response.total == 3
9898
assert response.limit == 1
9999
assert response.offset == 1
100100
assert len(response.feeds) == 1
101101
assert response.feeds[0].stable_id != first_feed.stable_id
102102

103-
response = await api.get_feeds(offset=3)
103+
response = api.get_feeds(offset=3)
104104
assert response.total == 3
105105
assert response.limit == 50
106106
assert response.offset == 3
107107
assert len(response.feeds) == 0
108108

109-
response = await api.get_feeds(limit=10)
109+
response = api.get_feeds(limit=10)
110110
assert response.total == 3
111111
assert response.limit == 10
112112
assert response.offset == 0
@@ -121,7 +121,7 @@ async def test_get_feeds_operation_status_filter():
121121
"""
122122
api = OperationsApiImpl()
123123

124-
base_response = await api.get_feeds()
124+
base_response = api.get_feeds()
125125
assert base_response is not None
126126

127127
feeds_by_status = {}
@@ -133,7 +133,7 @@ async def test_get_feeds_operation_status_filter():
133133
if status == "none":
134134
continue
135135

136-
response = await api.get_feeds(operation_status=status)
136+
response = api.get_feeds(operation_status=status)
137137
assert response is not None
138138
assert response.total == feeds_by_status[status]
139139
assert len(response.feeds) == feeds_by_status[status]
@@ -147,24 +147,24 @@ async def test_get_feeds_combined_filters():
147147
"""Test get_feeds with multiple filters applied."""
148148
api = OperationsApiImpl()
149149

150-
base_response = await api.get_feeds()
150+
base_response = api.get_feeds()
151151
assert base_response is not None
152152

153-
gtfs_response = await api.get_feeds(data_type="gtfs")
153+
gtfs_response = api.get_feeds(data_type="gtfs")
154154
assert gtfs_response is not None
155155

156-
wip_response = await api.get_feeds(operation_status="wip")
156+
wip_response = api.get_feeds(operation_status="wip")
157157
assert wip_response is not None
158158

159-
response = await api.get_feeds(data_type="gtfs", operation_status="published")
159+
response = api.get_feeds(data_type="gtfs", operation_status="published")
160160
assert response is not None
161161
wip_gtfs_feeds = response.feeds
162162

163163
assert len(wip_gtfs_feeds) == 1
164164
assert wip_gtfs_feeds[0].data_type == "gtfs"
165165
assert wip_gtfs_feeds[0].operational_status == "published"
166166

167-
response = await api.get_feeds(data_type="gtfs", limit=1, offset=1)
167+
response = api.get_feeds(data_type="gtfs", limit=1, offset=1)
168168
assert response is not None
169169
assert len(response.feeds) == 1
170170
assert response.offset == 1
@@ -181,7 +181,7 @@ async def test_get_feeds_unpublished_status():
181181
api = OperationsApiImpl()
182182

183183
# Test with unpublished status filter
184-
response = await api.get_feeds(operation_status="unpublished")
184+
response = api.get_feeds(operation_status="unpublished")
185185
assert response is not None
186186
for feed in response.feeds:
187187
assert feed.operational_status == "unpublished"
@@ -197,7 +197,7 @@ async def test_get_feeds_all_operational_statuses():
197197

198198
# Test each operational status
199199
for status in ["wip", "published", "unpublished"]:
200-
response = await api.get_feeds(operation_status=status)
200+
response = api.get_feeds(operation_status=status)
201201
assert response is not None
202202
for feed in response.feeds:
203203
assert feed.operational_status == status
@@ -210,17 +210,13 @@ async def test_get_feeds_unpublished_with_data_type():
210210
"""
211211
api = OperationsApiImpl()
212212

213-
gtfs_response = await api.get_feeds(
214-
operation_status="unpublished", data_type="gtfs"
215-
)
213+
gtfs_response = api.get_feeds(operation_status="unpublished", data_type="gtfs")
216214
assert gtfs_response is not None
217215
for feed in gtfs_response.feeds:
218216
assert feed.operational_status == "unpublished"
219217
assert feed.data_type == "gtfs"
220218

221-
rt_response = await api.get_feeds(
222-
operation_status="unpublished", data_type="gtfs_rt"
223-
)
219+
rt_response = api.get_feeds(operation_status="unpublished", data_type="gtfs_rt")
224220
assert rt_response is not None
225221
for feed in rt_response.feeds:
226222
assert feed.operational_status == "unpublished"
@@ -235,25 +231,25 @@ async def test_get_feeds_search_query():
235231
"""
236232
api = OperationsApiImpl()
237233

238-
response = await api.get_feeds(search_query="RT")
234+
response = api.get_feeds(search_query="RT")
239235
assert response is not None
240236
assert response.total == 1
241237
assert len(response.feeds) == 1
242238
assert response.feeds[0].feed_name == "London Transit Commission(RT"
243239

244-
response = await api.get_feeds(search_query=" Provider B ")
240+
response = api.get_feeds(search_query=" Provider B ")
245241
assert response is not None
246242
assert response.total == 1
247243
assert len(response.feeds) == 1
248244
assert response.feeds[0].provider == "provider B"
249245

250-
response = await api.get_feeds(search_query="mdb-41")
246+
response = api.get_feeds(search_query="mdb-41")
251247
assert response is not None
252248
assert response.total == 1
253249
assert len(response.feeds) == 1
254250
assert response.feeds[0].stable_id == "mdb-41"
255251

256-
response = await api.get_feeds(search_query="mdb")
252+
response = api.get_feeds(search_query="mdb")
257253
assert response is not None
258254
assert response.total == 3
259255
assert len(response.feeds) == 3

0 commit comments

Comments
 (0)