Skip to content

Commit b792ca2

Browse files
committed
fixed broken tests
1 parent e0c75c6 commit b792ca2

File tree

3 files changed

+14
-43
lines changed

3 files changed

+14
-43
lines changed

api/src/feeds/impl/search_api_impl.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,6 @@ def search_feeds(
127127
db_session: "Session",
128128
) -> SearchFeeds200Response:
129129
"""Search feeds using full-text search on feed, location and provider's information."""
130-
# logging params
131-
print("limit: ", limit)
132-
print("offset: ", offset)
133-
print("status: ", status)
134-
print("feed_id: ", feed_id)
135-
print("data_type: ", data_type)
136-
print("is_official: ", is_official)
137-
print("search_query: ", search_query)
138-
print("features: ", features)
139130
query = self.create_search_query(status, feed_id, data_type, is_official, search_query, features)
140131
feed_rows = Database().select(
141132
session=db_session,

api/tests/integration/test_search_api.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ def test_search_feeds_all_feeds(client: TestClient, search_query: str):
2323
"""
2424
Retrieve all feeds with a search query using provider or feed name.
2525
"""
26-
params = [
27-
("limit", 100),
28-
("offset", 0),
29-
("feed_id", ""),
30-
("data_type", ""),
31-
("search_query", search_query),
32-
]
26+
params = [("limit", 100), ("offset", 0), ("feed_id", ""), ("data_type", ""), ("search_query", search_query)]
3327
headers = {
3428
"Authentication": "special-key",
3529
}
@@ -67,13 +61,7 @@ def test_search_feeds_all_feeds_with_limit(client: TestClient, search_query: str
6761
"""
6862
Retrieve 2 feeds using limit with a search query using provider or feed name.
6963
"""
70-
params = [
71-
("limit", 100),
72-
("offset", 0),
73-
("feed_id", ""),
74-
("data_type", ""),
75-
("search_query", search_query),
76-
]
64+
params = [("limit", 2), ("offset", 0), ("feed_id", ""), ("data_type", ""), ("search_query", search_query)]
7765
headers = {
7866
"Authentication": "special-key",
7967
}
@@ -441,14 +429,14 @@ def test_search_filter_by_official_status(client: TestClient, values: dict):
441429
@pytest.mark.parametrize(
442430
"values",
443431
[
444-
{"features": "Text-To-Speech", "expected_count": 3},
445-
{"features": "Fare Products", "expected_count": 2},
446-
{"features": "Levels", "expected_count": 1},
432+
{"features": "", "expected_count": 16},
433+
{"features": "Bike Allowed", "expected_count": 2},
434+
{"features": "Stops Wheelchair Accessibility", "expected_count": 0},
447435
],
448436
ids=[
449-
"Accessibility",
450-
"Fares",
451-
"Pathways",
437+
"All",
438+
"Bike Allowed",
439+
"Stops Wheelchair Accessibility",
452440
],
453441
)
454442
def test_search_filter_by_features(client: TestClient, values: dict):
@@ -474,17 +462,18 @@ def test_search_filter_by_features(client: TestClient, values: dict):
474462
assert response.status_code == 200
475463

476464
# Parse the response body into a Python object
477-
response_body = SearchFeeds200Response.parse_obj(response.json())
465+
response_body = SearchFeeds200Response.model_validate(response.json())
478466
expected_count = values["expected_count"]
479467
assert (
480468
response_body.total == expected_count
481469
), f"There should be {expected_count} feeds with features={values['features']}"
482470

483471
# Verify all returned feeds have at least one of the requested features
484472
if values["features"] and expected_count > 0:
485-
requested_features = values["features"].split(",")
473+
requested_features = set(values["features"].split(","))
486474
for result in response_body.results:
475+
features = result.latest_dataset.validation_report.features
487476
# Check that at least one of the feed's features is in the requested features
488-
assert any(
489-
feature in requested_features for feature in result.features
490-
), f"Feed {result.id} does not have any of the requested features: {requested_features}"
477+
assert requested_features.intersection(features), (
478+
f"Feed {result.id} with features {features} does not match " f"requested features {requested_features}"
479+
)

docs/DatabaseCatalogAPI.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ paths:
5050
- $ref: "#/components/parameters/provider"
5151
- $ref: "#/components/parameters/producer_url"
5252
- $ref: "#/components/parameters/is_official_query_param"
53-
- $ref: "#/components/parameters/features"
5453

5554
security:
5655
- Authentication: []
@@ -455,14 +454,6 @@ components:
455454
note:
456455
description: A note to clarify complex use cases for consumers.
457456
type: string
458-
features:
459-
description: >
460-
A list of GTFS features associated to the feed.
461-
type: array
462-
items:
463-
type: string
464-
example:
465-
["Text-To-Speech", "Headsigns", "Wheelchair Accessibility"]
466457

467458
GtfsFeed:
468459
allOf:

0 commit comments

Comments
 (0)